aspose file tools*
The moose likes Servlets and the fly likes Request in sessionDestroyed of HttpSessionListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request in sessionDestroyed of HttpSessionListener" Watch "Request in sessionDestroyed of HttpSessionListener" New topic
Author

Request in sessionDestroyed of HttpSessionListener

AshishP Gandhi
Greenhorn

Joined: Aug 05, 2007
Posts: 9
Hi All,
I am having the below problem...Can someone suggest a way to solve it ?

We have a cookie set when any user logs in on our site..
What i want to do is, when the session expires ie. it is idle for some time, i would like to delete the cookie which i am creating on login.
I tried with HttpSesionListener, sessionDestroyed (), but there is no request object in it to destroy the cookie..
Can any one have some other way to delete the cookie ??

Waiting for some response....Thanks in advance...
Ashish.


Regards,
Ashish.
Raju Goke
Greenhorn

Joined: May 01, 2007
Posts: 7
set the max age to zero by using setMaxAge(0).


-Raju
AshishP Gandhi
Greenhorn

Joined: Aug 05, 2007
Posts: 9
ya tht is fine but I want to do that only on my session getting expired...how do i come to kno when session expires
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Ashish.

Store the cookie set in application scope. During session invalidation, container/server calls the HttpSessionListener's sessionDestroyed(HttpSessionEvent se) method. In that method provide,
Then it will be garbage Collected.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
i would like to delete the cookie which i am creating on login.


You can only change the cookies stored on the user's browser when processing a response which goes to the browser.

There is no way you can reach out in cyberspace and delete that cookie if the user isn't talking to you.

Time to rethink your problem. Do a search for rfc2965 to get the API which governs cookies.

Bill
Rahul Juneja
Ranch Hand

Joined: Aug 03, 2002
Posts: 425
William Brogden wrote:
i would like to delete the cookie which i am creating on login.


You can only change the cookies stored on the user's browser when processing a response which goes to the browser.

There is no way you can reach out in cyberspace and delete that cookie if the user isn't talking to you.

Time to rethink your problem. Do a search for rfc2965 to get the API which governs cookies.

Bill


Bill,

Your point is very valid but the problem mentioned also seems to be a very practical problem, so what do you or other suggest the solution for this kind of a problem.

Thanks,
Rahul


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Don't use cookies to determine if the user is logged in or not. Use the session.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: Request in sessionDestroyed of HttpSessionListener