简体   繁体   English

如何检查用户是在一个选项卡上登录该站点而不是在同一浏览器中的另一个选项卡上?

[英]How can you check if a user is logged into the site on one tab but not on another tab from the same browser?

GitHub recently implemented a feature whereby if you're viewing a page as a guest in one tab then log into the site from another tab, in the tab where you are still a guest, it will display the following message: GitHub最近实现了一项功能,如果您在一个选项卡中以一个访客的身份查看某个页面,然后从另一个选项卡登录该站点,在您仍然是访客的选项卡中,它将显示以下消息: 在此输入图像描述

This works the same when the tabs are in an incognito/private window. 当标签位于隐身/私人窗口中时,此功能相同。

Does the site/session variables force the client-side to check for existing cookies? 站点/会话变量是否强制客户端检查现有cookie?

If this is purely out of curiosity, there are ways to easily add this. 如果这纯粹是出于好奇,有办法轻松添加它。 As you mentioned, when the page is opened, it would be checking the saved cookies, finding the saved SessionID and checking it with the backend to see if it is still an active session. 正如您所提到的,当页面打开时,它将检查已保存的Cookie,查找已保存的SessionID并使用后端进行检查以查看它是否仍为活动会话。 Upon the page being closed, this sessionID would then be cleared and removed from the static list on the backend. 在页面关闭后,此会话ID将被清除并从后端的静态列表中删除。 You should be able to fill in the missing gaps from here. 你应该能够从这里填补缺失的空白。

Easiest to manage cookies with PHP, calling it with javascript, if you need an idea of a direction to take. 如果您需要了解方向,可以使用PHP轻松管理cookie,使用javascript调用它。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何限制登录用户使用其他浏览器/选项卡再次登录? - How can I restrict logged in user from logging in again using another browser/tab? 您可以检查Web应用程序是否已在另一个浏览器选项卡上运行吗? - Can you check if a web application is already running on another browser tab? 如何将用户从一个选项卡重定向到另一页的另一选项卡? - How to redirect an user from one tab to another tab of other page? 如何从另一个标签中选择浏览器标签? - How to select a browser tab from another tab? 如何将浏览器焦点从一个标签更改为另一个标签 - How to change browser focus from one tab to another 我如何知道我的网站不在同一浏览器的另一个选项卡上运行? - How Do I know my site is not running on another tab in a same browser? 在同一浏览器中打开新标签页时如何关闭标签页? - How can close the tab when open the new tab in same browser? 当用户离开我的网站时如何更改浏览器中的标签名称 - How to change tab name in browser when user goes off from my site 如何知道用户是否从不同的选项卡登录到我的 SAAS - How to know if user is logged in to my SAAS from different tab 如何在选项卡视图页面中从一个选项卡切换到另一个选项卡? - How to shift from one tab to another in a page of tab view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM