ASP session variable lost
On PageA.asp I set a session variable like so
Session("affiliate") = "xyz.com"
When I click a link and go to PageB.asp that session variable no longer exists.
开发者_开发知识库I have other session variables and they persist across the pages. I can response.write my session varriable on PageA.asp, so I know it gets created properly.
I had this problem a few months back. I figured it out then, sometime between now and then my fix got overwritten. Now, I'm at a total loss.
Thanks in advance.
You're probably clearing the variable somewhere else in your site.
There is another issue I discovered not long ago. If you are on 2008-2003 server(IIS6-7) then make sure that you are not using any other port but 80.
For some reason latest versions IIS losing session on redirect, if website set to use any other port but 80.
I submitted bug report to Microsoft but so far no word from them how or what they going to do to fix this.
Is PageB.asp on the same domain? cross domain sessions will not work. Same domain sessions should not clear unless you are resetting it or clearing the contents.
Do you have the code where you populate the session?
if other session variables are still usable on PageB.asp than this should work as well..
UNLESS,
- youve set it to expire to fast.
- you have a typo in the session variable name on pageB.asp. copy paste from pageA to pageB.
without seeing the code related to the session variables from pageA and pageB its quite hard to guess..
as for your comment regarding the loss of session variables try:
<%
dim i
For Each i in Session.StaticObjects
Response.Write(i & "<br />")
Next
%>
this should list all the objects stored in session
No matter what I did, the session variable was getting lost on response.redirects. I ended up using a cookie.
For IIS6 our major session killer was the load balancer. The fix for this is to convert to IIS 7. It handles sessions between the balanced servers. Yes we put gobs of stuff in cookies to handle it too.
Try limiting the "Web Garden" Worker processes to 1.
Find it here:
"IIS Mananger" --> "App Pool" --> "Properties" --> "Performance" tab --> "Maximum number of worker processes"
精彩评论