Anything in the session just stays there. If you don't want to access a session variable on that page, then don't access it. The problem with using session in the way you are using it is normally the data hanging around when it shouldn't. For the data
that is only used for a certain page it might be worth removing the session variable after you access it so it is a "one time read", but that depends on your logic.
I'm afraid I no longer use this forum due to the new point allocation system.
Member
34 Points
461 Posts
Retrieve Session
Jul 27, 2014 11:10 AM|SlyF0x|LINK
Page 1
Session["name"] //this session is only needed for Page3.aspx
Session["number"] //this session is needed for Page 2
Respone.redirect ("Page2.aspx")
Session["name"] is only needed for Page3.aspx, how am I going to store this and retrieve to Page3.aspx
The order is Page1.aspx > Page2.aspx > Page3.aspx, cannot jump page.
All-Star
37441 Points
9076 Posts
Re: Retrieve Session
Jul 27, 2014 11:14 AM|AidyF|LINK
Anything in the session just stays there. If you don't want to access a session variable on that page, then don't access it. The problem with using session in the way you are using it is normally the data hanging around when it shouldn't. For the data that is only used for a certain page it might be worth removing the session variable after you access it so it is a "one time read", but that depends on your logic.
Member
34 Points
461 Posts
Re: Retrieve Session
Jul 27, 2014 11:20 AM|SlyF0x|LINK
Can I do this?
On the Page2.aspx, retrieve the Session["name"], and den response.redirect("Page3.aspx");
All-Star
37441 Points
9076 Posts
Re: Retrieve Session
Jul 27, 2014 11:36 AM|AidyF|LINK
Yes you can do that.