Balconsky
Balconsky

Reputation: 2244

Logout with jsf and page redirection

I have pages with logout button, which invalidates session and redirct to login page. This works well. But I also need to invalidate session after timeout.

At server side session also invalidates well, but when server invalidate session, page also should be redirected to login page. Now it works with meta-tag:

<meta http-equiv="refresh" content="900; URL=/MyApplication-web/ibm_security_logout?logoutExitPage=/" />

This says browser after 15 minutes(timout) redirect to URL address, where logout actually happening.

I use JSF SessionBeans, user works with one page throw ajax, and after 15 minutes with one page browser redirect this to logout page.

How to synchronize redirection to logout page with server side timout logout?

Upvotes: 3

Views: 810

Answers (1)

Adrian Mitev
Adrian Mitev

Reputation: 4752

This could be done using a custom Servlet and ajax polling. Poll the Servlet using ajax every N seconds. In the servlet you can check if the http session is new (there is such method in HttpSession interface) and if the session is new that means the previous (the working session) has timed out. There is an article describing the solution + implementation using Seam2, however you could port it to any framework.

Upvotes: 1

Related Questions