会话变量失去价值
我使用会话变量来存储不同的信息。当我使用 JavaScript 重定向时,会话变量似乎失去了它们的值。这种情况发生得非常不一致,特别是在 Chrome 中(其他浏览器都很好!)
window.location = "../submitOrder.php?custid="+custid;
(在我放入整个 url 的实际代码中)
然后,从 SubmitOrder 开始,我的会话变量是空白的......
这可能是什么原因?这与重定向有关吗?
我不介意添加更多必要的细节,但问题是一个简单但令人困惑的问题。
谢谢你!
I am using session variables to store different pieces of information. The minute I redirect using javascript the session variables seem to lose their values. this happens very inconsistanly especialy in Chrome (other browsers are fine!)
window.location = "../submitOrder.php?custid="+custid;
(in the real code i put in the whole url)
then, starting from the submitOrder my session variables are blank...
what could be the cause of this? does it have to do with the redirect?
I don't mind adding more details of necessary, but the problem is a simple but confusing one.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我不太了解 Chrome 在 Javascript 重定向和 cookie 处理方面的行为,但您的问题表明,当您在 Chrome 中通过 Javascript 重定向用户时,会话 cookie 未正确传递到服务器上。
对于是否确实如此,您可以将会话 ID 作为重定向的一部分,即:
但是我认为 Chrome 中不太可能存在此类问题,您的代码中可能有错误(也许您忘记使用 start_session () 功能?)
While I am not particularly aware of Chromes behavior regarding Javascript redirects and cookie handling your problem suggests that the session cookie isn't correctly passed onto the serven when you redirect a user via Javascript in Chrome.
To whether this really is the case you could make the session id a part of your redirect, i.e.:
However I think it is unlikely that such issue exists in Chrome, you probably have a mistake in your code (maybe you forgot to use the start_session() function?)