Java HttpCookie setHttpOnly() Method22 Mar 2025 | 2 min read The setHttpOnly(Boolean httpOnly) method of Java HttpCookie class is used to indicate whether the cookie can be considered as HTTPOnly or not. If it is set to true then the cookie cannot be accessed by scripting engines like JavaScript.
SyntaxParameterThe above method requires only one parameter:
ReturnN.A. Example 1Output: Check whether the cookie is HTTPOnly: true Example 2Output: Check whether the cookie is HTTPOnly: false Example 3Output: Check whether the first cookie is HTTPOnly:true Check whether the second cookie is HTTPOnly:false Next TopicsetMaxAge() Method |
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India