每次只允许一个会话 [英] Allow one session only at a time

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

问题描述

我想提出我的网站,允许在同一时间只有一个会话。例如,让我们说用户已经登录到我的Firefox的网站,如果用户再次登录时像在同一台计算机或不同计算机上的歌剧其他浏览器,Firefox的会话将被销毁。然而,在Firefox中的会话保持,如果它仍然是一个会话。我想知道我该怎么做呢?我使用PHP和Apache。谢谢你。

I would like to make my website to allow only one session at a time. For example, let say user has login to my website on firefox, if the user login again to another browser like opera on the same computer or different computer, the session on firefox will be destroyed. However, the session on firefox remained if it remains as one session. May I know how can I do that? I am using php and apache. Thank you.

问候。
本杰明

Regards. Benjamin

推荐答案

我会建议你做这样的事情:

I'll suggest you to do something like this:

假设当用户A的包厢中的COM_1,为第一次。保存独特code反对该会话的数据库,并与用户会话一样的。

Suppose when user "A" loges in to the "Com_1", for the first time. Save a unique code in the database against that session, and same with the user session.

目前的平均时间,如果他(用户A)中再次COM_2包厢,再检查他的状态在数据库和更新数据库中的独特code。

At the mean time if he (user "A") loges in again on "com_2", then check his status in the database and update the unique code in the database.

再回来,如果同一用户(A)刷新的COM_1的页面中,我们所有你需要做的就是从会话检查独特code和它匹配的数据库,这是肯定的它不会匹配,然后注销出来,并摧毁了会议。

again back if same user (user "A") refreshes the page on "com_1", we all you need to do is check the unique code from the session and match it to the database, It is for sure it will not match, then log it out and destroy the session.

有关保持用户的loggedIn,即使关闭浏览器,您可以将存储的cookie的浏览器,并accoordingly重新生成会话。

For keeping the user loggedin, even if browser is closed, you can store the cookie on the browser, and re-generate the session accoordingly.

希望这有助于。谢谢你。

Hope this helps. Thank you.

这篇关于每次只允许一个会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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