在两个不同的Web浏览器之间共享会话 [英] Sharing session between two different web browser
问题描述
我想制作一个 PHP Web应用程序,其中在同一台PC上一次只能进行一个身份验证会话,即使用 Firefox登录用户A ,但是用户B 无法在同一台PC上使用 IE 登录
I want to make a PHP web application in which on a single PC there can only be one authentication session at a time i.e. User A login using Firefox, but User B cannot login using IE on the same PC
如果我从服务器端询问,则我无法执行Google搜索的浏览器之间的会话共享
Of what i googled session sharing between browsers can not be done if asked from server side
推荐答案
从理论上讲,您可以使用 session_id()和一个数据库条目,尽管安全性很棘手,因为恶意用户可以尝试生成随机会话ID来模仿已登录用户的会话.
Theoretically, you could do this using session_id() and a database entry, although security will be tricky since a malicious user could try generating random session IDs to mimic a logged-on user's session.
会话信息以指定的ID存储在客户端浏览器的cookie中.通过存储该ID和数据的JSON字符串,每当更新时,各种用户都可以共享相同的数据.他们都必须不时轮询服务器,以查看数据是否已更改.
Session information is stored in a cookie in the client's browser, with a specified ID. By storing that ID and a JSON string of the data, whenever it's updated, various users could conceivably share the same data. They'd all have to poll the server once in a while to see if the data has been changed.
但是到那时,您不再需要使用$_SESSION
了,因此它已经大大超出了您提出问题的目的.您可以使用常规变量获得相同的行为,这已经是安全性方面的改进.
But at that point, you don't need to use $_SESSION
anymore, so it's pretty much defeated the purpose of your question. You can get the same behavior with regular variables, which would already be a security improvement.
简短的回答:不,那不是会议的重点.
Short answer: No, that's not the point of sessions.
这篇关于在两个不同的Web浏览器之间共享会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!