从所有会话注销 [英] Logout from all session

查看:44
本文介绍了从所有会话注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个退出选项,这是我的代码:

I have a option for logout and here is my code:

session_start();

session_destroy();

setcookie("key","",time()-60*60*24);

setcookie("username","",time()-60*60*24);

我想添加另一个选项以退出所有会话(在另一台设备上)例如,如果用户更改了他的密码,则该用户的所有会话都将被清除并全部注销.

I want to add another option to logout from all session ( on another device ) for example if user change his password, all session for this user be clear and logout from all.

如何在所有设备上编辑所有会话?我可以将会话 ID 存储到数据库,并使用会话密钥更改数据吗?(不是当前用户)

How can I edit all session on all devices? Can I store session id to database, and change data with session key ? ( not current user )

推荐答案

最好的办法是创建自己的数据库库 会话处理程序.

Best bet here would be to create your own database base session handler.

届时,您将对会话的功能有很大的控制权.有一篇很好但过时的文章这里 展示了如何做到这一点的示例完毕.

You will have a lot of control over what you can do with the sessions then. There is a good but dated article here that shows an example of how that can be done.

这篇关于从所有会话注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆