Reputation: 489
Could someone tell me how to delete the cookie that is either in memory of on hardrive in java on the client side? Just like how browser deletes all the cookies and session information.
I'm trying to do some PoC's for my work and I'm using simple apache Http classes for sending requests and then passing cookies in multiple requests but what if let's say I want to delete my session that is stored in the cookie.
I think this can be done because all browsers let you do this.
Upvotes: 1
Views: 3704
Reputation: 284
Cookies (client side) are the equivalent of sessions (server side). I don't think there is a way to force the browser to delete the cookie, but you can suggest it to do so by:
Ending the session on server side:
HttpSession session = request.getSession();
session.invalidate();
or setting a short session period of timeout:
HttpSession session = request.getSession();
session.setMaxInactiveInterval(1*60); //in seconds
Upvotes: 1