Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends.
I have a question about session expiration.
does the memory that is for a variable get clear when session expires?
in the other words can we use our global variables after session expiration?
thanks in advanced.
Posted
Comments
kornakar 6-Jul-12 3:47am    
I think you should avoid using global variables as much as possible. Try to think another way of doing what you want (cookies perhaps, or a database?).

1 solution

A variable is cleared when you are not using it and the garbage collector is ready to clean it up.
This has nothing to do with session variables.

Session state is nothing more than memory in the shape of a dictionary or hash table, e.g. key-value pairs, which can be set and read for the duration of a user's session. This dictionary is linked to the session.
Once the timeout expires, ASP.NET terminates an inactive Session and disposes of the state for that session.
Thus the dictionary is destroyed.

Thus from your question's point of view, the variable and session stated are independent things and one being disposed does not mean the other has been disposed.

These are some great links -
http://msdn.microsoft.com/en-us/magazine/cc163730.aspx[^].
http://msdn.microsoft.com/en-us/library/ff647327.aspx#diforwc-ch05_cachingstate[^]
 
Share this answer
 
Comments
Manas Bhardwaj 6-Jul-12 3:54am    
Well exlained +5
Abhinav S 6-Jul-12 3:55am    
Thank you Manas.
Rahul Rajat Singh 6-Jul-12 3:55am    
+5.
Abhinav S 6-Jul-12 3:59am    
Thank you Rahul.
[no name] 6-Jul-12 3:58am    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900