File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Programmatically removing a cookie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Programmatically removing a cookie" Watch "Programmatically removing a cookie" New topic
Author

Programmatically removing a cookie

MalanS Subramanian
Greenhorn

Joined: Jul 09, 2005
Posts: 8
Hi Ranchers,
Is it possible to programatically remove a cookie? I tried looking in Servlet API and couldnt find any...

Thanks in advance
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Malan. Can you please tell, in which situations this behaviour is needed? Thankyou.
MalanS Subramanian
Greenhorn

Joined: Jul 09, 2005
Posts: 8
Hi Chinmaya,
I dont have any situations as such in my mind, but was just wondering whether this is doable.
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Malan. Thanks for the reply. There is no remove method available in Servlet api. If we want to restrict particular client we can follow better alternatives, like filtering. As far my knowledge concerned, this behavior is not needed.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
It is possible to remove a cookie, you just need a little workaround.

Retrieve the cookie, set MaxAge to 0 and reinsert it.


JDBCSupport - An easy to use, light-weight JDBC framework -
MalanS Subramanian
Greenhorn

Joined: Jul 09, 2005
Posts: 8
Hi Sebastian,
Thanks for the reply... thats a cute lil workaround
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Apart from being cute, it's pretty much the only way to remove a cookie from the server side,,,
 
 
subject: Programmatically removing a cookie