Yes. Of course, if the application is unloaded due to inactivity and the session is stored in memory it will be lost. Normally the application pool will recycle when the application hasn't been in use for a while, usually 20 minutes or more. This saves on
server resources such as memory and connections in the database connection pool and allows it to free up items that weren't properly handled in the garbage collection. Generally, don't could on session lasting for a long time and you should be prepared in
case the values come up null so your application doesn't crash, and you can possibly reload some of them without the user noticing any glitch.
Don't forget to mark useful responses as Answer if they helped you towards a solution.
bobwhite
Member
701 Points
667 Posts
Session.Timeout
Feb 24, 2012 09:48 PM|LINK
Hi,
HttpContext.Current.Session["name"] = CONTRACTS_CALL;
HttpContext.Current.Session.Timeout = 60 * 8;
markfitzme
Star
14319 Points
2215 Posts
Re: Session.Timeout
Feb 24, 2012 10:16 PM|LINK
Yes. Of course, if the application is unloaded due to inactivity and the session is stored in memory it will be lost. Normally the application pool will recycle when the application hasn't been in use for a while, usually 20 minutes or more. This saves on server resources such as memory and connections in the database connection pool and allows it to free up items that weren't properly handled in the garbage collection. Generally, don't could on session lasting for a long time and you should be prepared in case the values come up null so your application doesn't crash, and you can possibly reload some of them without the user noticing any glitch.
roopeshreddy
All-Star
20125 Points
3323 Posts
Re: Session.Timeout
Feb 25, 2012 08:53 AM|LINK
Hi,
Yeah! Ususally no one keep 480 mins active sessions! max of 20-30 mins!
You can keep ur your value! There is no limitation!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
bobwhite
Member
701 Points
667 Posts
Re: Session.Timeout
Feb 29, 2012 07:19 PM|LINK
Hi
So, can I say that I always check the session var if it is created or not before using it. like
if (Session["myVarName"] != null
.... then I can use it, this way, I will not have any error if the session object is not created.... Am I right
roopeshreddy
All-Star
20125 Points
3323 Posts
Re: Session.Timeout
Feb 29, 2012 10:44 PM|LINK
Hi,
Yeah!
Session will be created always! You are checking for the values stored in the session!
And yes, what you did is correct! you need to check for the NULL condition before using it! Good Practise!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space