Session/Cookies not getting set (Post, Redirect)
I'm having a big problem with Session and Cookies in Classic ASP.
I have "a.asp" where I set the Session("step") = "1"
. This works and when I call my "test.asp" where I do <%=Session("step")%>
I get "1".
Then I submit the form on "a.asp" to "process.asp" where I set other session-variables based on the submitted form values. Finally I redirect to "b.asp".
On "b.asp" I check if Session("step") = "1"
and set it to "2" if it was "1" and redirect to "a.asp" otherwise. I write the Session("step")
on the page and it says "2" but when I call "test.asp" it says "1".
It seems like the page itself got the right value but a reload or any other page ignores the change of session/cookie value.
Tried the same with Cookies (Response.Cookies("step")
/Request.Cookies("step")
) and I got the same result.
Pages are all in the same folder and there is only 1 worker-thread on the IIS.
Just can't figure out why th开发者_开发技巧e session and cookie are not getting set. Any advice appreciated!
(Can't seem to comment, but need some clarification. Will edit/delete this answer as appropriate. anyways....)
It could be a caching issue:
- Have you tried CTRL+F5 to make sure your browser is reloading.
- Try in another browser, I have found Firefox and Chrome both ignore forced cache refreshes sometimes, or try in "private" mode.
- Does your host have a load balancer or caching system? Add a random querystring to each request to test.asp to make sure.
- You can force no-caching, but some browsers, ISPs and Hosters ignore it anyway...
.
Response.Expires = 0
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Apologies if you have tried all this, would have rather asked with a quick comment!
精彩评论