ASP session variable lost

拈花ヽ惹草 提交于 2019-12-25 04:55:23

问题


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.


回答1:


You're probably clearing the variable somewhere else in your site.




回答2:


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.




回答3:


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?




回答4:


if other session variables are still usable on PageB.asp than this should work as well..

UNLESS,

  1. youve set it to expire to fast.
  2. 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




回答5:


No matter what I did, the session variable was getting lost on response.redirects. I ended up using a cookie.




回答6:


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.




回答7:


Try limiting the "Web Garden" Worker processes to 1.

Find it here:

"IIS Mananger" --> "App Pool" --> "Properties" --> "Performance" tab --> "Maximum number of worker processes"



来源:https://stackoverflow.com/questions/3144185/asp-session-variable-lost

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!