When Session Variables Go Bad

Summary

So what have we learned from all of this. First, it is not a good idea to store STA objects in the Session variables. You might get away with it on a low volume site, but if you do run into strange problems, be aware that the problem could be causes by STA objects. And, unfortunately, the most common objects used by ASP developers use the STA architecture, namely ADO and FileSystemObjects.

Second, if you do use Session variables, be aware of how much information is actually being stored. Especially if you have a heavily trafficked site, make sure that you adjust your memory (both physical and virtual) accordingly.

Finally, if you move to a distributed web server environment, the use of Session variables can decrease performance by not letting the load balancing service do its thing. Should you ever use Session variables? They are too compelling (in my opinion) to answer with a flat "NO". However, their simplicity belies the caution and thought that should go into their use.

You might also like...

Comments

About the author

Bruce Johnson Canada

I am the owner of a small application development consulting company that specialized in the design and implementation of Internet-based applications. While there are others who can make a web ...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“To iterate is human, to recurse divine” - L. Peter Deutsch