gopal
gopal

Reputation: 3741

closing all web pages on session time out

When a session is timed out in asp.net application, we need to close all the web pages those are already opened by a user.

Each page has sign out link. When the user click on that link, the home page is redirected to that page.

In this case, the other opened pages also needs to be closed.

How can we do this?

Upvotes: 1

Views: 1233

Answers (3)

Vinz
Vinz

Reputation: 2005

As Razzie commented, doing an AJAX callback to the same web-application will keep the session alive. Using a web-service also won't solve the problem.

This solution avoids keeping the session alive:

  • Store every session in the database. This could be done in the Session_Start event in the Global.asax or after the log-in.
  • Delete timed-out sessions from the database in the Session_End event in your Global.asax file or after the log-out.
  • Do a periodical AJAX callback to a different web-application, e.g. a web running on a sub-domain, to check in the database if the session still exists.

I suggest you use the SessionID to identify the sessions.

Upvotes: 0

The King
The King

Reputation: 4650

On the second thought... we can use what @thephpdeveloper said, particularly when user signs out formally... (like clicking the signout button) Once After a formal Sign out happens... Such Ajax Call back can be used, cause the session will be valid but there will not be any user... Using this we can signal the page and close the browser window

Upvotes: 0

mauris
mauris

Reputation: 43619

For all pages:

  1. AJAX call back to server to check whether Session has expired.
  2. Parse result from AJAX
  3. If session ended then close window or redirect to logged out page.

Upvotes: 1

Related Questions