Thursday, November 4, 2010

expire a cookie in java

To expire a cookie, the maxAge of the cookie should be set to 0 and then the cookie should be added back into response.

Once the browser gets the response, it will find out the cookie with same name, domain name, path and then expire it.

In java code when the first time we get the cookie, if the domain or path is changed before added in the response, when you are going to expire that cookie in your java code, you should keep the cookie in same name, domain name and path.

//cookie.setDomain("same with the cookie domain in browser which is going to be expired");
//cookie.setPath("same with the cookie path in browser which is going to be expired")

No comments:

Post a Comment