PHP-结束会话 ID
我正在尝试删除会话 ID,我尝试了以下所有此处,< a href="https://stackoverflow.com/questions/1226040/is-this-a-proper-way-to-destroy-all-sessions-in-php">此处,以及 此处。但它们都不起作用。
我应该做什么很简单,只从当前 php 页面中删除会话 ID(而不是会话本身)。我想要完成的是调用 ajax,其中会话 ID 将被删除,而当前页面将继续与会话一起运行。
我应该为此使用什么?
谢谢你!
I'm trying to delete session ID, I tried all of the following here, here, and here. But none of them work.
What should I do very simpy to just delete the session ID from the current php page (but not the session itself). What I am trying to accomplish is to call an ajax where the session ID will be deleted, while the current page will keep running with the session.
What should I use for this?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于特定页面,您可以使用以下命令取消设置会话 ID
unset($_SESSION['id'])
但要将其保留在原始页面上,您需要将其打包到临时变量中,并在 ajax 调用后重新声明它,
即在原始页面上
$tmpsessionid = $_SESSION['id '];
ajax 调用完成 - 重新注册会话
$_SESSION['id'] = $tmpsessionid;
有人会问你为什么要这样做?
for a specific page you can unset the session id with
unset($_SESSION['id'])
but to keep it on the original page you would need to pack it into a temp variable, and re-declare it after your ajax call
ie on original page
$tmpsessionid = $_SESSION['id'];
ajax call finished - reregister session
$_SESSION['id'] = $tmpsessionid;
One would have to ask why you are trying to this though?