-
Session variable problems
I have two ASP pages in my project that are having problems with session variables.
In Page1.asp I set the session variables when I click a submit button, which
will also take me to Page2.asp where I use the session variables.
The first time through everything works great. The session variables have
values in Page2.asp. Now, while at Page2.asp, I use the browser "Back" button
to go back to the first page. Again, I click the submit button which will
take me to Page2.asp. This time when I get to Page2.asp, the session variables
are empty.
On the second execution the session variables do have values on Page1.asp.
Why are the session variables losing their values on Page2.asp?
TIA
Nate
-
Re: Session variable problems
It sounds like your variables that you are using to assign the session variables
are some type of user input box, and that when you hit the back button, they
are in the field where you entered them, but they may not be visable to the
script. Have you tried changing them after the back button to see if the
changed ones carry forward to page2.ap? If they do carry forward after being
changed you may need to reassign your field value using the session variable.
kelley...
"Nate" <nkane@enak.com> wrote:
>
>I have two ASP pages in my project that are having problems with session
variables.
>
>In Page1.asp I set the session variables when I click a submit button, which
>will also take me to Page2.asp where I use the session variables.
>
>The first time through everything works great. The session variables have
>values in Page2.asp. Now, while at Page2.asp, I use the browser "Back" button
>to go back to the first page. Again, I click the submit button which will
>take me to Page2.asp. This time when I get to Page2.asp, the session variables
>are empty.
>
>On the second execution the session variables do have values on Page1.asp.
>
>Why are the session variables losing their values on Page2.asp?
>
>TIA
>Nate
>
-
Re: Session variable problems
Kelly,
Thanks for your resonse. I have done further research and found that the
original developer put in Session.Abandon to clear any session variables
when you enter the initial screen. This is what we want.
Now the problem goes back to the original problem. Let me see if I can explain
it here.
We can enter a number on page1.asp, click a button which takes us to page2.asp
and everything is fine. The number entered on page1.asp gets passed to page2.asp
through session variable.
If the user clicks on the browsers "Back" button we are back at page1.asp.
Now when we enter a new number on page1.asp the code will not recognize the
value that we just entered on page1.asp. We are forced to enter the number
again and click the button. It always works the second time.
Any ideas?
Nate
"ke11ey" <ke11eyh@zdnetonebox> wrote:
>
>It sounds like your variables that you are using to assign the session variables
>are some type of user input box, and that when you hit the back button,
they
>are in the field where you entered them, but they may not be visable to
the
>script. Have you tried changing them after the back button to see if the
>changed ones carry forward to page2.ap? If they do carry forward after being
>changed you may need to reassign your field value using the session variable.
>
>kelley...
>"Nate" <nkane@enak.com> wrote:
>>
>>I have two ASP pages in my project that are having problems with session
>variables.
>>
>>In Page1.asp I set the session variables when I click a submit button,
which
>>will also take me to Page2.asp where I use the session variables.
>>
>>The first time through everything works great. The session variables have
>>values in Page2.asp. Now, while at Page2.asp, I use the browser "Back"
button
>>to go back to the first page. Again, I click the submit button which will
>>take me to Page2.asp. This time when I get to Page2.asp, the session variables
>>are empty.
>>
>>On the second execution the session variables do have values on Page1.asp.
>>
>>Why are the session variables losing their values on Page2.asp?
>>
>>TIA
>>Nate
>>
>
-
Re: Session variable problems
Nate
I can’t help thinking that is sounds like the abandon method is resetting
your session variables when you return to the page. Is there some reason
why you are not using the request.form(“”) to pass your variables to the
second page. I hate to be so dense, but let me paraphrase what I think you
said.
User starts application.
All session variables are reset with the abandon method.
User enters values into input text field.
User clicks on submit button.
Second page is displayed with the values from the first page, via the session
variables.
User clicks the back button
(User is now back at first page, which contains residual values from previous
entry?)
User clicks submit button again (with out entering anything into input text
fields, relying on the residual values from the previous entry)
Second page is displayed but no values from the first page.
User clicks the back button
User re-enters the values and clicks the submit button.
Second page is displayed with the values from the first page.
** do I have it right?
"Nate" <nkane@enak.com> wrote:
>
>Kelly,
>Thanks for your resonse. I have done further research and found that the
>original developer put in Session.Abandon to clear any session variables
>when you enter the initial screen. This is what we want.
>
>Now the problem goes back to the original problem. Let me see if I can explain
>it here.
>
>We can enter a number on page1.asp, click a button which takes us to page2.asp
>and everything is fine. The number entered on page1.asp gets passed to page2.asp
>through session variable.
>
>If the user clicks on the browsers "Back" button we are back at page1.asp.
>Now when we enter a new number on page1.asp the code will not recognize
the
>value that we just entered on page1.asp. We are forced to enter the number
>again and click the button. It always works the second time.
>
>Any ideas?
>
>Nate
>
>"ke11ey" <ke11eyh@zdnetonebox> wrote:
>>
>>It sounds like your variables that you are using to assign the session
variables
>>are some type of user input box, and that when you hit the back button,
>they
>>are in the field where you entered them, but they may not be visable to
>the
>>script. Have you tried changing them after the back button to see if the
>>changed ones carry forward to page2.ap? If they do carry forward after
being
>>changed you may need to reassign your field value using the session variable.
>>
>>kelley...
>>"Nate" <nkane@enak.com> wrote:
>>>
>>>I have two ASP pages in my project that are having problems with session
>>variables.
>>>
>>>In Page1.asp I set the session variables when I click a submit button,
>which
>>>will also take me to Page2.asp where I use the session variables.
>>>
>>>The first time through everything works great. The session variables have
>>>values in Page2.asp. Now, while at Page2.asp, I use the browser "Back"
>button
>>>to go back to the first page. Again, I click the submit button which will
>>>take me to Page2.asp. This time when I get to Page2.asp, the session variables
>>>are empty.
>>>
>>>On the second execution the session variables do have values on Page1.asp.
>>>
>>>Why are the session variables losing their values on Page2.asp?
>>>
>>>TIA
>>>Nate
>>>
>>
>
-
Re: Session variable problems
Kelly,
You have the process correct.
There are some other reasons that they are doing things the way they are.
I am a consultant and have inherited this code from a former employee of
the company that hired me to fix their problems.
I just ran through a test of using the request.querystring("") and was able
to pass all of the values to page2.asp and everything worked pretty well.
Once I got to page2.asp I was able to reset the session variables. However,
I think that I am going to run into trouble doing this. The way things are
setup I think that I could get into trouble with Request.Form("") also.
Below is the code from page1.asp that I used to pass the session variables:
if (Session("costcenter") <> "") then
Session.Abandon
end if
--- there is some code here to set the session variables ---
strPass = "?costcenter=" & Session("costcenter") & _
"&costcentercode=" & Session("costcentercode") & _
"&userlogon=" & Session("userlogon") & _
"&opalpath=" & Session("opalpath") & _
"&asppath=" & Session("asppath") & _
"&serverpath=" & Session("serverpath")
Response.Redirect "Page2.asp" & strPass
My question is why do the session variables have values here but not when
I get to page2.asp?
Thanks
Nate
"ke11ey" <ke11eyh@zdnetonebox.com> wrote:
>
>Nate
>
>I can’t help thinking that is sounds like the abandon method is resetting
>your session variables when you return to the page. Is there some reason
>why you are not using the request.form(“”) to pass your variables to the
>second page. I hate to be so dense, but let me paraphrase what I think you
>said.
>User starts application.
>All session variables are reset with the abandon method.
>User enters values into input text field.
>User clicks on submit button.
>Second page is displayed with the values from the first page, via the session
>variables.
>User clicks the back button
>(User is now back at first page, which contains residual values from previous
>entry?)
>User clicks submit button again (with out entering anything into input text
>fields, relying on the residual values from the previous entry)
>Second page is displayed but no values from the first page.
>User clicks the back button
>User re-enters the values and clicks the submit button.
>Second page is displayed with the values from the first page.
>** do I have it right?
>
>
>"Nate" <nkane@enak.com> wrote:
>>
>>Kelly,
>>Thanks for your resonse. I have done further research and found that the
>>original developer put in Session.Abandon to clear any session variables
>>when you enter the initial screen. This is what we want.
>>
>>Now the problem goes back to the original problem. Let me see if I can
explain
>>it here.
>>
>>We can enter a number on page1.asp, click a button which takes us to page2.asp
>>and everything is fine. The number entered on page1.asp gets passed to
page2.asp
>>through session variable.
>>
>>If the user clicks on the browsers "Back" button we are back at page1.asp.
>>Now when we enter a new number on page1.asp the code will not recognize
>the
>>value that we just entered on page1.asp. We are forced to enter the number
>>again and click the button. It always works the second time.
>>
>>Any ideas?
>>
>>Nate
>>
>>"ke11ey" <ke11eyh@zdnetonebox> wrote:
>>>
>>>It sounds like your variables that you are using to assign the session
>variables
>>>are some type of user input box, and that when you hit the back button,
>>they
>>>are in the field where you entered them, but they may not be visable to
>>the
>>>script. Have you tried changing them after the back button to see if the
>>>changed ones carry forward to page2.ap? If they do carry forward after
>being
>>>changed you may need to reassign your field value using the session variable.
>>>
>>>kelley...
>>>"Nate" <nkane@enak.com> wrote:
>>>>
>>>>I have two ASP pages in my project that are having problems with session
>>>variables.
>>>>
>>>>In Page1.asp I set the session variables when I click a submit button,
>>which
>>>>will also take me to Page2.asp where I use the session variables.
>>>>
>>>>The first time through everything works great. The session variables
have
>>>>values in Page2.asp. Now, while at Page2.asp, I use the browser "Back"
>>button
>>>>to go back to the first page. Again, I click the submit button which
will
>>>>take me to Page2.asp. This time when I get to Page2.asp, the session
variables
>>>>are empty.
>>>>
>>>>On the second execution the session variables do have values on Page1.asp.
>>>>
>>>>Why are the session variables losing their values on Page2.asp?
>>>>
>>>>TIA
>>>>Nate
>>>>
>>>
>>
>
-
Re: Session variable problems
I keep coming back to the session.abandon statement, have you tried running
the code with that rem'ed out or removed and see how it performs then. If
it performs Ok without the session.abandon statement, then ...
"Nate" <nkane@enak.com> wrote:
>
>Kelly,
>
>You have the process correct.
>
>There are some other reasons that they are doing things the way they are.
>I am a consultant and have inherited this code from a former employee of
>the company that hired me to fix their problems.
>
>I just ran through a test of using the request.querystring("") and was able
>to pass all of the values to page2.asp and everything worked pretty well.
>Once I got to page2.asp I was able to reset the session variables. However,
>I think that I am going to run into trouble doing this. The way things are
>setup I think that I could get into trouble with Request.Form("") also.
>
>Below is the code from page1.asp that I used to pass the session variables:
>
>if (Session("costcenter") <> "") then
> Session.Abandon
>end if
>
>--- there is some code here to set the session variables ---
>
>strPass = "?costcenter=" & Session("costcenter") & _
> "&costcentercode=" & Session("costcentercode") & _
> "&userlogon=" & Session("userlogon") & _
> "&opalpath=" & Session("opalpath") & _
> "&asppath=" & Session("asppath") & _
> "&serverpath=" & Session("serverpath")
>Response.Redirect "Page2.asp" & strPass
>
>My question is why do the session variables have values here but not when
>I get to page2.asp?
>
>Thanks
>Nate
>
>"ke11ey" <ke11eyh@zdnetonebox.com> wrote:
>>
>>Nate
>>
>>I can’t help thinking that is sounds like the abandon method is resetting
>>your session variables when you return to the page. Is there some reason
>>why you are not using the request.form(“”) to pass your variables to the
>>second page. I hate to be so dense, but let me paraphrase what I think
you
>>said.
>>User starts application.
>>All session variables are reset with the abandon method.
>>User enters values into input text field.
>>User clicks on submit button.
>>Second page is displayed with the values from the first page, via the session
>>variables.
>>User clicks the back button
>>(User is now back at first page, which contains residual values from previous
>>entry?)
>>User clicks submit button again (with out entering anything into input
text
>>fields, relying on the residual values from the previous entry)
>>Second page is displayed but no values from the first page.
>>User clicks the back button
>>User re-enters the values and clicks the submit button.
>>Second page is displayed with the values from the first page.
>>** do I have it right?
>>
>>
>>"Nate" <nkane@enak.com> wrote:
>>>
>>>Kelly,
>>>Thanks for your resonse. I have done further research and found that the
>>>original developer put in Session.Abandon to clear any session variables
>>>when you enter the initial screen. This is what we want.
>>>
>>>Now the problem goes back to the original problem. Let me see if I can
>explain
>>>it here.
>>>
>>>We can enter a number on page1.asp, click a button which takes us to page2.asp
>>>and everything is fine. The number entered on page1.asp gets passed to
>page2.asp
>>>through session variable.
>>>
>>>If the user clicks on the browsers "Back" button we are back at page1.asp.
>>>Now when we enter a new number on page1.asp the code will not recognize
>>the
>>>value that we just entered on page1.asp. We are forced to enter the number
>>>again and click the button. It always works the second time.
>>>
>>>Any ideas?
>>>
>>>Nate
>>>
>>>"ke11ey" <ke11eyh@zdnetonebox> wrote:
>>>>
>>>>It sounds like your variables that you are using to assign the session
>>variables
>>>>are some type of user input box, and that when you hit the back button,
>>>they
>>>>are in the field where you entered them, but they may not be visable
to
>>>the
>>>>script. Have you tried changing them after the back button to see if
the
>>>>changed ones carry forward to page2.ap? If they do carry forward after
>>being
>>>>changed you may need to reassign your field value using the session variable.
>>>>
>>>>kelley...
>>>>"Nate" <nkane@enak.com> wrote:
>>>>>
>>>>>I have two ASP pages in my project that are having problems with session
>>>>variables.
>>>>>
>>>>>In Page1.asp I set the session variables when I click a submit button,
>>>which
>>>>>will also take me to Page2.asp where I use the session variables.
>>>>>
>>>>>The first time through everything works great. The session variables
>have
>>>>>values in Page2.asp. Now, while at Page2.asp, I use the browser "Back"
>>>button
>>>>>to go back to the first page. Again, I click the submit button which
>will
>>>>>take me to Page2.asp. This time when I get to Page2.asp, the session
>variables
>>>>>are empty.
>>>>>
>>>>>On the second execution the session variables do have values on Page1.asp.
>>>>>
>>>>>Why are the session variables losing their values on Page2.asp?
>>>>>
>>>>>TIA
>>>>>Nate
>>>>>
>>>>
>>>
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks