Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closing the browser should actually clear the session variables an ASP.net session id

I have an ASP.net page. When I am closing the webpage I need to clear the session variables.

How to to handle this I need to maintain the timeout to 20 minutes. If he closes and login for any number of times in the 20 minutes timed out time

Is there any possiblity for clearing the ASP.net session id

like image 321
balaweblog Avatar asked Nov 30 '22 07:11

balaweblog


1 Answers

You cannot do that.

  1. You cannot rely on a event happening on the browser
  2. There is no way the server can contact the browser to see if it is alive

You do not control the browser of the end-user. The user might close the browser, crash, disconnect from the Internet, have javascript disabled or crashed, etc, etc. Or the user might just enter another url (and after that the user might return to your page by using the back button, and expect to continue his/her session with your site).

The window.onbeforeunload is triggered with every unload of the page. Even if the user browses to another page on your site, so they might need your session again.

like image 193
GvS Avatar answered Dec 05 '22 00:12

GvS