desiguy
desiguy

Reputation: 651

log out a user on session expiration

What is the best way to force a user to login again if the session expires. I am using forms authentication. Also the solution needs to work even if user has multiple tabs opened in the browser.

Upvotes: 0

Views: 1875

Answers (1)

mgnoonan
mgnoonan

Reputation: 7200

This happens automatically. Once the session is expired, the next page the user requests that requires authentication should redirect to the login page. If you mean that you want the page no longer displayed if left sitting for too long, there are a couple of approaches.

  1. Add a META REFRESH tag to every page header. The refresh time should be close or equal to the session timeout. Note that if you make AJAX calls, the refresh tag does not reset the timer to zero.

  2. Use the Javascript setTimeout function to redirect just before the session timeout.

Upvotes: 6

Related Questions