Listener for Session Expiration in Spring

12,317

Maybe SessionManagementFilter could help?

Or you can configure Spring Security to automatically redirect user if timeout occured: Detecting timeouts section.

Share:
12,317
Prashant
Author by

Prashant

Working in Java and Related technology

Updated on June 12, 2022

Comments

  • Prashant
    Prashant almost 2 years

    I am new to spring security and using it for authentication. I am facing a issue that when the browser is closed or in case of any unusual failure the session expires but I am unable catch the event so as to get the clean up code executed. I explore about it and found HttpSessionEventPublisher in Spring to capture HttpSessionDestroyedEvent in sessionDestroyed() method but that is not called when I close the browser.

    Request to suggest solution for the same.

  • Prashant
    Prashant over 10 years
    SessionManagementFilter will help me trace and authenticate every request, but on closing browser no such request is send at server.
  • Prashant
    Prashant over 10 years
    i haven't tries this but what will happen if javascript is disable or if system crashes.
  • Human Being
    Human Being over 10 years
    JavaScript must to be enabled.Today, there is no web application without javascript.
  • Cem Sultan
    Cem Sultan over 10 years
    @HyperLink Can this also be done using just JQuery without Ajax as our system just uses straight Spring MVC with direct client communication? Thanks.