session in asp.net is getting close after 2-3 minutes

1.8k Views Asked by At

I have made a web application which uses user authentication and if user is authenticated user then i store it in Session like below.

Session("uid") = txtUid.text

But after 2-3 minutes Session is automatically cleared.

3

There are 3 best solutions below

2
On BEST ANSWER

2 - 3 minutes?

it means that you are not sure how long it takes for the session to close.

from here i can assume that you are using internet explorer?

internet explorer has a known issue with asp.net, if you have an underscore in your virtual path like

www.mySite.com/some_test_site.aspx

so i bet you have a scenario like this.

in any case, you can add the following line to your web.config to keep vars for 60 minutes:

<sessionState mode="InProc" timeout="60"/>

it goes under:

<configuration>
   <system.web>
0
On

increase your session time in Web.config

 <system.web>
    <sessionState timeout="260"  />
  </system.web>
0
On

You can set the session state of your web application in web.config. Add this code in the Configuration section of your web.config.

<configuration>
  <system.web>
  ...
   <sessionState timeout="20" />
  ...
 </system.web>
</configuration>