php销毁一个不是当前会话的会话
如果用户打开一个会话,我想销毁他可能拥有的所有其他会话.
If a user opens a session, I would like to destroy all other sessions that he might have.
我知道 session_destroy();
但它只会破坏当前会话.
I know session_destroy();
but it destroys only the current session.
如何销毁另一个会话?(我知道另一个会话ID)
How can I do to destroy another session? (I know the other session id)
如果您有要销毁的会话的会话 ID,可以将其传递给 session_start()
以恢复该会话,销毁它,然后再次调用 session_start()
以创建新会话.我还没有尝试过以确认它会起作用,但似乎应该可以.
If you have the session id for the session you want to destroy, you can pass it to session_start()
to resume that session, destroy it, then call session_start()
again to create the new session. I haven't tried this to confirm it will work, but it seems like it ought to.
如果您没有想要销毁的会话的会话 ID,我不确定是否有一种理智、干净、可移植的方式来做到这一点.
If you do not have the session id for the session you want to destroy, I'm not sure there's a sane, clean, portable way to do this.