• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Request in sessionDestroyed of HttpSessionListener

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't use cookies to determine if the user is logged in or not. Use the session.
 
reply
    Bookmark Topic Watch Topic
  • New Topic