Java HttpCookie setHttpOnly() MethodThe 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 1Test it NowOutput: Check whether the cookie is HTTPOnly: true Example 2Test it NowOutput: Check whether the cookie is HTTPOnly: false Example 3Test it NowOutput: Check whether the first cookie is HTTPOnly:true Check whether the second cookie is HTTPOnly:false Next TopicsetMaxAge() Method |
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