I want the user to be logged in until the user closes the browser window or specifically logs out. how this can be done? Should I use UserIsOnlineTimeWindow?
2 Answers
Use a javascript "keep alive" mechanism.
You will have to use a javascript setInterval to keep making ajax requests to your server.
This keeps the session alive for as long as the browser is open.
Note that is is a security risk, it is usually good to stop making these requests by clearing the interval after a definitely amount of time.
Extending the session timeout by setting it to very large number won't scale very well for a large number of users
You can set the session timeout in web.config...the max valid value of which 525601 minutes (1 year) - default is 20mins
<system.web>
<sessionState timeout="20" />
<system.web>
-
The max value is one day, 1440 minutes. msdn.microsoft.com/en-us/library/ms525473%28v=vs.90%29.aspx Aug 28, 2012 at 13:05
-
not accoring to MSDN it's not msdn.microsoft.com/en-us/library/h6bb9cz9(v=vs.100).aspx Aug 28, 2012 at 13:08
-
Beware: Extending the session timeout will mean that those sessions will take up memory for the entire period - can your server handle that? Aug 28, 2012 at 13:39