cometta cometta - 1 year ago 74
Java Question

servlet set cookie secure?

javax.servlet.http.Cookie implements java.lang.Cloneable

In Cookie method, there is a method call "setSecure" , what does it use for? if i setSecure(true), is there anything i need to do on my client(javascript) side to read the cookie? what is different set/without setSecure?

Answer Source

All that setSecure(true) does is tell the browser that the cookie should only be sent back to the server if using a "secure" protocol, like https. Your JavaScript code doesn't have to do anything different.