In my application, at lime of login I am creating a cookie(AAA). On Logout I am able to delete the cookie. At auto session timeout redirecting user to login page but not able delete(Expire) the cookie(AAA). I am using Jboss AS 7.1, spring-3.1 and spring-security in my application.
Following is http tag configuration in my security.xml
<http auto-config="true" use-expressions="true" entry-point-ref="customLoginUrlAuthenticationEntryPoint" disable-url-rewriting="true">
<request-cache ref="httpSessionRequestCache"/>
<session-management invalid-session-url="/ctx/login?invalid-session=true" session-authentication-error-url="/ctx/login?session-auth-error=true">
<concurrency-control max-sessions="1" expired-url="/ctx/login?expired=true" error-if-maximum-exceeded="true" />
</session-management>
<form-login authentication-success-handler-ref="customAuthenticationSuccessHandler"
authentication-failure-handler-ref="customPageHandler"
login-processing-url="/j_spring_security_check"/>
<custom-filter before="ANONYMOUS_FILTER" ref="anonymousFilter"/>
<custom-filter before="FORM_LOGIN_FILTER" ref="customFilter"/>
<custom-filter before="LOGOUT_FILTER" ref="logoutFilter" />
</http>
I have tried the following options
Option 1- Created a HttpFilter to refresh the cookie and synchronizing the time between session and cookie.
Option 2- Created a HttpFilter for login page url(/login), Filter gets invoked for login page and delete the cookie.
Option 1 doesn't seem to work because I can see the cookie after session gets timedout. And the problem with option 2 is, if a logged user try to request the login page again from same browser with different tab, filter gets invoked and deletes the cookie. Which is bad. Because the cookie is required for further communication.
Could you please help me on what is the right way to delete the cookie.
Also I wanted to mention that filter gets invoked before HttPSessionListene#sessionDestroyed method.