当用户关闭浏览器时,如何使我的网站自动注销? [英] How do I make my site automatically sign out a user when they close their browser?

查看:93
本文介绍了当用户关闭浏览器时,如何使我的网站自动注销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个登录表格。成功登录后,我将重定向到登录的主页。目前,当我不注销而关闭此页面并重新打开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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆