用户可以使用不同的浏览器登录两次 [英] user can login twice by using different browser

查看:203
本文介绍了用户可以使用不同的浏览器登录两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在php中创建用户无法使用2种不同浏览器登录两次的代码。


我的数据库中有一个colom user_session。


如果他登录2次,第二次重定向到主页面。

在firefox或chrome中,我的代码也可以。

但是如果你使用2个浏览器就可以登录两次。


我的网站是一个聊天室。


有2个用户inlog 1 inlog是他们都可以打字并去不同的房间。


i dunno为什么你看不到第二次登录他的名字已经消失了。


请帮助。

How can i make a code in php that user can not login twice by using 2 different browsers.

I have in my database a colom user_session.

If he logs in in Ie 2 times ,the second time he re-direct to the main page.
In firefox or chrome my code works too.
But if you use 2 browsers you can login twice.

My site is a chatsite.

with 2 user inlog 1 inlog is invisible and one not.
they both can type and go to different rooms.

i dunno why you can not see the second login his name has gone.

please help.

推荐答案

每个浏览器都有自己的会话信息并拥有自己的cookie空间。因此,每当您使用两个浏览器登录时,就像两个单独的系统一样运行。


现在,您可以添加另一个列session_status,您可以在其中输入active / deactive。


每当用户尝试使用其他浏览器登录时,它将检查存储的会话是活动的还是非活动的。如果处于活动状态,则显示一条消息并确认用户使用密码再次登录新的新浏览器,如果成功,则将活动会话重写为deactive并存储新的浏览器会话。并且每个聊天消息将在更新聊天消息之前检查浏览器会话和数据库存储的会话是否等于。如果不匹配,那么浏览器将显示一条消息并重定向到登录页面。


希望它能为您提供帮助。 :)
Every browser has it''s own session information and has it''s own cookie space. so, whenever you use two browsers to log in those acts like two individual system running.

Now, you can add another column session_status where you can input active/deactive.

whenever a user trying to log in using another browser it will check the stored session is active or deactive. if active, then it show a message and confirms user log in again of new new browser using password and if successful then it rewrite the active session to deactive and store new browser session. And every chat message will check the browser session and the database stored session equals or not before updating the chat message. if not matched then browser will show a message and redirect to log in page.

Hope it''s help you. :)


@ariful alam


现在我可以继续使用我的剧本。

祝你有愉快的一天。


:)
@ariful alam

Ty very much now i can go on with my script.
Have a nice day.

:)


顺便说一下,这个解决方案也可以防止多次登录电脑。如果您只是想阻止多个浏览器,但允许它们从多台计算机登录,那么您还需要跟踪IP地址或用户代理(这也是存储活动/非活动状态的好主意)。


如果有人试图从同一个浏览器登录两次怎么办?即从第二个选项卡或使用浏览器历史记录中的登录页面再次登录?


在做这样的用户检测时有很多想法。


祝你好运,


Dan
By the way, this solution also will prevent multiple logins from different computers. If you are just trying to prevent multiple browsers but enable them to login from multiple computers, then you also need to track IP address or user agent (which is also a good idea to store along with active/deactive status).

what if someone try''s to login from the same browser twice? i.e. from a second tab or uses login page in browser history to login again?

Lots to think about when doing user detection like this.

Good luck,

Dan


这篇关于用户可以使用不同的浏览器登录两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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