网页中的会话。如何自动退出
当我们在一个选项卡中登录 gmail 并在另一个选项卡中登录 orkut 时(请记住,两者只能是同一帐户。登录一个选项卡会自动登录到另一个选项卡)。如果我们从 gmail 注销,然后转到 orkut 已打开的选项卡,则在页面中保留几秒钟后,页面会自动注销。这是怎么做到的?我认为这是通过页面刷新实现的,但想知道有什么更好的方法,因为我不想一次又一次地传输这么多数据。
When we sign into gmail in one tab and orkut in another(remember both can only be of the same account. Logging into one automatically logs into another). if we log out from gmail and then go to the tab in which orkut is already open, after remaning in the page for a few seconds the page automatically logs out. How is this done? i assume this is through page refresh but would like to know of any better way since i dont want to transfer so much data again and again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google 的单点登录服务器知道您的帐户已注销,因此下次任何 Google 服务验证您的凭据时,它都会返回您已注销的信息,以便应用程序可以采取相应的操作。
至于如何在不刷新整个页面的情况下做到这一点,很可能是 XHR(AJAX 请求)实际上使页面注销。这可能不是一个明确的“检查凭据”请求,而是这些应用程序默认编写的任何常规请求(在 GMail 上检查电子邮件、在 Orkut 上检查新朋友或其他内容)触发凭据检查。
Google's Single Sign On server knows that your account has been logged out, so next time any Google service validates your credentials, it returns that you've logged out so the app can act accordingly.
And about how to do it without having to refresh the whole page, it's very likely a XHR (AJAX request) which actually makes the page log out. It's probably not an explicit 'check for credentials' request, but any regular request that those apps have programmed by default (check for email on GMail, check for new friends or whatever on Orkut) that triggers the credentials check.