简体   繁体   English

当用户关闭浏览器时,如何使我的网站自动注销?

[英]How do I make my site automatically sign out a user when they close their browser?

Let's suppose I have a sign-in form. 假设我有一个登录表单。 When I sign in successfully I am redirected to the logged in home page. 成功登录后,我将被重定向到登录的主页。 Currently, when I close this page without signing out, and re-open Firefox, this logged in home page is started again. 当前,当我不退出而关闭此页面并重新打开Firefox时,此登录的主页将再次启动。

I want it so that when the user closes their browser the session is the session is expired and when they next open Firefox the logged-in home page isn't displayed. 我想要这样,以便当用户关闭其浏览器时,会话即会话已过期,而当他们下次打开Firefox时,不会显示登录的主页。

I think session will be used for this, but I don't know how I can set a time or even make it so that when Firefox closes the closes session get destroyed. 我认为会话将​​用于此目的,但是我不知道如何设置时间,甚至无法设置时间,以便在Firefox关闭时关闭会话。

Set your session timeout to 15 minutes, this should do the job. 将您的会话超时设置为15分钟,这应该可以完成。 You cannot catch the "close browser" or "close tab" event for sure (no javascript enabled, browser just crashes, etc), so you shouldn't go for that. 您不能确定捕获“关闭浏览器”或“关闭选项卡”事件(未启用JavaScript,浏览器崩溃等),因此您不应该这样做。

Check Felix' post for additional information where to set the session timeout exactly. 查看Felix的文章,以获取其他信息,以了解确切设置会话超时的位置。

Pardon me if I am stepping on toes as non-server HTML programmer, but could you check to see if the browser already has a cookie from a previous session? 如果我以非服务器HTML程序员的身份踏上脚步,请原谅我,但是您能检查一下浏览器是否已有上一个会话的cookie吗? Even if the answer is yes, if it is a new session, force an authentication? 即使答案是肯定的,即使是新会话,也要强制进行身份验证?

Just a thought. 只是一个想法。

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

相关问题 浏览器关闭时如何自动注销用户? - How to automatically log out user when browser closes? 当用户关闭任何特定选项卡时如何显示提示? (这是关于单个选项卡,而不是所有浏览器的) - How do i show prompt when user close any particular tab? (This is about individual tab not for all browser) 关闭浏览器时自动注销用户 - Automatically Log-Out Users When They Close Their Browser 如何让我的网站自动缩小到 90% - How can I make my website automatically zoom out to 90% CodeIgniter如何使会话在用户浏览器上关闭 - CodeIgniter how to make a session to close on user browser close 如何使用PayPal在我的网站上实现“兑现”? - How do I implement “cash out” on my site using PayPal? 如何在我的网站ssl上填写表格 - How do I make a form on my site ssl 如何保护用户在我的网站上传的私密照片? - How do I secure private photos that a user uploads on my site? 如何在用户登录时显示“下载”和“实时预览”按钮,而在用户注销时仅显示“实时预览”按钮? - How do I make “download” and “Live Preview” buttons appear when user logged in but only “Live Preview” button when user logged out? 当有人登录我的网站时,如何自动创建phpBB会话? (单点登录) - How can I automatically create a phpBB session when someone logs onto my website? (Single sign-on)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM