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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session variable problems 1

Status
Not open for further replies.

cosmoh2o

Programmer
Jul 22, 2002
92
0
0
US
Please help,

I have three asp .net pages page1.aspx page2.aspx and page3.aspx. The first page (page1.aspx) prompts the user to enter a total number which is stored as a Session variable called "TOTAL" another session variable called "LAST" is set to 0 and the program redirects to page2.aspx. page2.aspx gets the values of session "LAST" and "TOTAL". "LAST" is incremented by 1 each time the page is loaded until "LAST" >= "TOTAL" at which point program redirects to page3.aspx. I want to implement a "loop" with asp .net pages. The program works fine until after the third iteration of page2.aspx. After the third iteration the session variables have no value. I don't know why this is and can find no information on it. Any help/hints would be wonderful.

Below is a sample of the code on page2.aspx (done in the on_page_load method):

dim total as string = Session("TOTAL")
dim last as string = Session("LAST")

if (last < total) then
'Does some stuff
Session(&quot;LAST&quot;) = Session(&quot;LAST&quot;) + 1
response.redirect(&quot;page2.aspx&quot;)
else
response.redirect(&quot;page3.aspx&quot;)
end if
 
This may be a little lame, but maybe adding a second or two delay a la System.Threading.Thread.Sleep(ms to each page might help. Maybe its kind of running over itself at some point.
 
Could be a session timeout. How is your timeout configured?
 
Sessions are set to 120 minutes - a little high but my boss wanted them set very high for this project.
 
&quot;dim total as string = Session(&quot;TOTAL&quot;)
dim last as string = Session(&quot;LAST&quot;)&quot;

Are your session variables stored as strings? The comparisons and incrementing may be getting thrown off. Why don't you extract the above as integers?
 
Thanks for all the suggestions. I will try to store the values as strings and see what that does.
 
Thanks to everyone for the help. I did BolderBum's suggestion and it worked perfectly. THANKS BolderBum!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top