Session["USER_ID"] = "1";
This is the session variable. I want to know how long the session variable value can be stored.
Session["USER_ID"] = "1";
This is the session variable. I want to know how long the session variable value can be stored.
Session duration in ASP.NET is 20 minutes. There are two ways to change the session duration:
<sessionState> field in the web.config file.Session.Timeout property in Session_Start() method in Global.asax.cs file.You can change the session duration in the web.config file as follows:
<configuration>
<system.web>
<sessionState mode="InProc" cookieless="false" timeout="60" />
</system.web>
</configuration>
You can change the session duration in the global.asax.cs file as follows:
public class ApplicationName : System.Web.HttpApplication
{
protected void Session_Start(object sender, EventArgs e)
{
/* Sets the session duration to 60 minutes. */
Session.Timeout = 60;
}
}