Session Variable not storing

shootsnlad

Freshman
Joined
Feb 14, 2002
Messages
46
Ok, I have a session variable called "CheckType". I have it in my global.aspx
blanked out:

Code:
Session("CheckType") = ""

I then have a page where I assign a value to it:

Code:
Session("CheckType") = "DIRECT"

I then do a Response.redirect onto another page. Then I try to reference the value of the session variable:

Code:
If Session("CheckType") = "DIRECT" then.....

It is always blank. Should I not have it in global.aspx?
 
Where in the global.asax are you setting the value to blank? Make sure it is not being overwritten with every page load.

Put a breakpoint on the Response.Redirect and check the contents of the Session variable right before you actually redirect.
 
shootsnlad said:
Ok, I have a session variable called "CheckType". I have it in my global.aspx
blanked out:

Code:
Session("CheckType") = ""

I then have a page where I assign a value to it:

Code:
Session("CheckType") = "DIRECT"

I then do a Response.redirect onto another page. Then I try to reference the value of the session variable:

Code:
If Session("CheckType") = "DIRECT" then.....

It is always blank. Should I not have it in global.aspx?

Take it out of your global.asax. I think you are confusing application variables with session variables.

A session variable, a cache variable, and a viewstate variable can be assigned or called from within any page in your application, just make sure you are using the correct one for what you are trying to accomplish.

Also, if you are still having problems with your session variable, make sure your settings are correct in your web.config file and that you aren't timing out.

Good Luck,
Brian
 
Back
Top