File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes HttpSesssionListener not called when cookies are cleared Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSesssionListener not called when cookies are cleared" Watch "HttpSesssionListener not called when cookies are cleared" New topic

HttpSesssionListener not called when cookies are cleared

Shaik Muhammad
Ranch Hand

Joined: Jul 16, 2008
Posts: 36
My application uses am implementor of HttpSessionListener to remove the HttpSession instance that is stored in a map when that session is invalidated. My problem is , after logging into the application, when i manually clear the cookies in my browser, this listener class is not called . How to get my application notified when cookies are cleared in the interim. Please help
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

Can't happen. How is the server going to be notified when you clear the cookies in the browser?

Besides, clearing the cookie does not invalidate the session. Rather, you've "orphaned" the session and it will eventually time out.

[Asking smart questions] [About Bear] [Books by Bear]
John Kimball
Ranch Hand

Joined: Apr 13, 2009
Posts: 96
Unless I'm missing something...

Your listener doesn't fire because clearing cookies doesn't send an event to the server (and nor should it).

Think of it this way: Say I have multiple session cookies to multiple servers (say, a 1000 of them) and the browser persists those cookies even if the server tells it NOT to.

Now suppose I close all browsers and open a new browser with a blank page and I clear the cookies. Should the browser contact EVERY single server?

I think that would be a nightmare!
I agree. Here's the link:
subject: HttpSesssionListener not called when cookies are cleared
It's not a secret anymore!