views:

446

answers:

4

I'm very confused when it comes to what actually decides the session time-out.

The web app needs to allow for a 20 minute "idle time" before logging (or throwing) users out. I've tried different setting on both sessionState and Recycle worker processes in IIS. The time-out remains too short and, as far as my quit-n-dirty, primitive tests have shown, a bit random.

I read somewhere that the default time-out is 20 minutes, but in my app it appears to be closer to five. Are there any easy ways to change this? The app is running .NET 3.5 on IIS 6.

EDIT: I just realized that the Entity Framework might have something to do with the problem, as the user content is held as a context in the entity framework. Is there any time limit for how long an entity is held?

+6  A: 

The user will be logged out based on your Authentication settings in the web.config.

The Session timout will be set in your session tag in the web.config.

If they are different then you will see "interesting" results.

ck
The sessionstate alone doesn't seem to do the trick. What's the difference between the two, and should/could I use both, if they're set to the same value?
Marcus L
In your web.config, in your Authentication setting, make sure it is also set to 20. Are you getting logged out, or a Session error?
ck
The session seemed to "forget" the entity that held user info. I played around with a lot of parameters, and solved it in the end. Your answer helped, so you get the answer-tag. ;)
Marcus L
Glad you got it sorted in the end :)
ck
+5  A: 

http://msdn.microsoft.com/en-us/library/ms972429.aspx

If you look in the web.config you can write some thing like this

<configuration>
  <sessionstate timeout="20" />
</configuration>

and there you can set you timeout..

Petoj
Thanks for your answer, but as I wrote in my question I already tried sessionstate, and still won't get the desired result.
Marcus L
well do you use the inbuild loginsystem or have you written you own and does the session time behave the same in the debug webserver?
Petoj
The login is specific for this system - when logging in, the username and password are checked against the database, and if an Entity is returned, the user is logged in as the usertype in the entity. I just realized the Entity Framework might have something to do with it.
Marcus L
+1  A: 

Use the sessionstate timeout. You do not want to use Recycle Worker, as this will recycle all sessions associated with that worker, every N minutes. It's a good idea to set Recycle Worker to a very high value if you are using the session variable.

C. Ross
+1 for explaining Recycle Worker, but as I wrote in my question, I tried sessionstate without getting the desired result.
Marcus L
A: 

If the sesson it not taking its value from the web.congig you can also set the sasson timeouw within IIS

webste properties > Home Directory > Configuration > Options

Make sure enable sesson state is selected and then set the time out in mins.

TheAlbear