ASp.NET: Increase session timeout or expiry time in web.config or Global.asax.

Aman Sharma

Here, I will explain how to set or increase session timeout or expiry time in webconfig file or in application.
By default session timeout is 20 minutes but sometimes it is required to increase or decrease the session timeout as per application requirement.
So we can set custom session timeout in webconfig or global.asax file in application.

Suppose we want to increase session timeout to 1 hour using webconfig file:

Then add following code in web.config file :
 <sessionState mode="InProc" timeout="60">

 <sessionState mode="InProc" cookieless="false"  timeout="60">

In Global.asax : Set Session time out on Session_Start event:
void Session_Start(object sender, EventArgs e)
// Code will run when a new session is started
Session.Timeout = 15;


Post a Comment

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !