How to Set Session Timeout in ASP.NET

There are two ways to set a session timeout in ASP.NET.

First method:

Go to web.config file and add following script where sessionstate timeout is set to 60 seconds

<configuration>  
<system.web>  
<sessionState mode="InProc" cookieless="true" timeout="60"/>  
</sessionState>  
</system.web>  
</configuration>  

Second method:

Go to global.asax file and write the code below. This code sets the current session Timeout to 60 seconds.  

void Session_Start(object sender, EventArgs e)  
{  
Session.Timeout = 60;  
}  

Post a Comment

0 Comments