I have been wrestling with this and getting nowhere so I decided to research and ask. The research did not turn up anything so here goes. I have a form that carries a session variable to another form and works fine. I want to have the user keep submitting that form to enter food preferences until they have entered all they choose. When I submit to the same asp page all of a sudden the Session variables disappear. Is there some rule somewhere that posting to the same page erases session variables? Flummoxed!
Session variables should be kept for the entire time the use is connected to the server, or the session times out. Without code, which you should post up if you need more help, I would say that either something is clearing the item, or the session is clearing out. Try to use a global.asa file and put in Session.Timeout = number of minutes you want to keep session. Most default to 20 minutes, but you can set it to whatever you want. If it isn't that, then you will need to look over your code and make sure something isn't resetting them. If you are adding the info to the same variable make sure you are using Session("myitem") = Session("myitem") & mynewstuff . Also you may want to look into cookies, if you have forms with additions over many pages, make the user save the info on their system, then your server doesn't do all the work, and all the info is stored until you need it. Check out this link for help on cookies: http://www.w3schools.com/asp/asp_cookies.asp
if (Request.Form("B2")="Finished adding items") then
'if this person's food is added, check if they are the last person and send to final page
If (Session("Fcount")= Session("Fmembers")) then
<Center><H1><Font Color="#000000">Add Food </Font></H1>
<% 'set Food = Preference in Foods table %>
<table border=0 width=420><tr><td>
<p>This is where you rate food to store your preferences for future use.</td></tr></table>
<Table border="1" cellpadding="0" cellspacing="0" Align="Center" borderColor="#000000" Background="" >
I was searching for a clue in a php forum on session variables and I saw this:
"Note that this only affects relative URLs, so if your site includes the http:// part in its URLs it will not work for you."
I looked and sure enough I had put full URL's in my Response.redirect statements and that is what erased the session and the variables. I changed them to relative and the variables stayed put!