Introduction
When the user closesIEOr other browsers,SessionThe object will not end.SessionIt is calculatedWeb. configAnd then disappear.This means that even if the browser is closed, the server will ignore the destruction of local users.SessionStorage. In this article, you can see how to maintainSessionObject validity.
This means that even if the browser is closed, the server will ignore the destruction of local users.SessionStorage. In this article, you can see how to maintainSessionObject validity.This sectionCodeHelp us maintainSessionObject validity, even if youWeb. configSetSession Timeout = 1.
Use the following code:
Create a newASP. NETProject
EditWeb. configFile
SetSessiontimeout value = 3Minutes
Add a newWebForm"Sessionalive. aspx"
SetWebform1.aspxDefault start page
Add the followingJavascriptCode inWebform1.aspx
< Script >
Function Sessionlive ()
{
VaR IMG = New Image ();
IMG. SRC = " Sessionalive. aspx " ;
Alert ( ' Called ' );
}< P>
function setsessonlive ()
{< br> window. setinterval ( " sessionlive () " , 2000 );
}< br> script >
In the webform1.aspx body onload called in event setsessonlive () method, session the object does not disappear when the browser is running. 3 the minute ends session object.