• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Request in sessionDestroyed of HttpSessionListener

 
AshishP Gandhi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raju Goke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set the max age to zero by using setMaxAge(0).


-Raju
 
AshishP Gandhi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use cookies to determine if the user is logged in or not. Use the session.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic