Global Session Variables and Session State

  • Thread starter Thread starter Earl Teigrob
  • Start date Start date
E

Earl Teigrob

I what to create global variables that are based on the user session. I
created a class that is instanced on session_start and hold all the users
global variables within that class. This works great unil the user stays on
the page for more then the timeout period (20 minutes or whatever) Then when
they click a link the next page breaks because the current session has timed
out . Because ASP.NET rebuilds the old page and then fires the event, if a
session varialbe has timed out, then it messes up the loading of that page
and causes an error. I sure wish that there was a way of delcaring an
instance class that could be global accross all pages of the web site.

Thanks for your input

Earl
 
The problem you are having is related to transfering information from one
page to another. Depending on how you transfer to another page, you need to
re-adjust your class. Transfering methods are overloaded with the second
parameter usually determining how the form variables and state is preserved.
You need to use this as a guide for your class as well. For example, if you
do a page transfer and set the preserve form to false, you need to clear out
your class values and re-initialize to keep it in sync. I think that is all
you are missing to make this work.
 
Back
Top