当用户关闭浏览器时,如何使我的网站自动注销? [英] How do I make my site automatically sign out a user when they close their browser?
问题描述
假设我有一个登录表格。成功登录后,我将重定向到登录的主页。目前,当我不注销而关闭此页面并重新打开Firefox时,此登录的主页将再次启动。
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.
推荐答案
您希望会话cookie的到期时间为0-
You want the session cookie to have an expire time of 0 - see:
http://php.net/manual/zh/function.setcookie.php
http://docs.php.net/manual/ zh_CN / session.configuration.php#ini.session.cookie-lifetime
这篇关于当用户关闭浏览器时,如何使我的网站自动注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!