Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Variables - Opinions

Status
Not open for further replies.

tschonken

Programmer
Jul 3, 2002
21
ZA
I would like to get other peoples view on the next statement. Good or bad, I think that a lot of people can benefit from this.<br>
I could not help but notice how many people uses session variables on this thread. Also a lot of replies inform people to use session variables. My opinion about session variables has always been to only use them when absolutely 100% neccessary, and even then try to get a way past them. The reason why I feel this way about session variables is that I have read on various occasions that session variables can be very &quot;heavy&quot; on the server, eating up memory etc. especially when a lot of them are used or when a web site gets a lot of hits. When it is a page not getting a lot of hits I suppose it should be all right to use them, but I always believed to always write code as effective as possible

Any thoughts???
 
Session variables can use up server resources (memory). I use them sparingly (only for those things which apply to a whole session). I always use them to detect a valid session after login session(&quot;authenticated&quot;) = true. I never use them to pass information from page to page (I use a querystring or a hidden form for sensitive info). You can also use a cookie so that the info is stored on the client machine.

Consider this - if you have 1000 simultaneous users and each one has 10K worth of session variables, you are using 10M of the server RAM... Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Unless you are storing very big session variables, or have a webfarm it is okay to use them. Passing variables from one page to another using get/post can be a security risk in certain situations.

If you are worried about the performance impact of sessions, you can also make a table in your database to keep track of them. I.e.

Make a table called usersession or something similar
In the table, make a row for each session, and store necessary data in the fields of that row. You could then do a SessionOnEnd to delete that row from the database when the session ends.
 
mwolf00 and baddos posts are right on target. I would just add that older versions of IIS documentation DID discuss the weight of session variables and later versions like 5 refered to optimization of session managment.

If ur building a high traffic site u should go read some IIS documentation to get the latest information.

Good luck
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top