关闭浏览器时,会话cookie会过期吗? [英] Do session cookies expire when the browser is closed?

查看:378
本文介绍了关闭浏览器时,会话cookie会过期吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP应用程序,在对用户进行身份验证后,我在其中设置了 $ _ SESSION [’user’] = logged 。我称它为loginpage.php。

I have a PHP application where I set $_SESSION['user']="logged" once a user is authenticated. I call this loginpage.php.

一旦通过身份验证并设置了会话变量,用户便被带到以以下几行开头的成员页面:

Once authenticated and the session variable set, the user is taken to a member page which starts with the lines:

<?php
session_set_cookie_params(0,'/');
session_start();
if($_SESSION['user'] != 'logged') {
header ("Location:loginpage.php");
}?>

当用户登录后,关闭浏览器,然后访问会员页面,我希望他能够重定向到loginpage.php。

When a user has logged in, closes the browser and then visits the members page, I expect him to be redirected to loginpage.php.

但是,这不会发生。会话cookie仍在浏览器中-我使用Firefox进行了测试。

However, this does not happen. The session cookie is still there in the browser - I tested this using Firefox.

有人可以向我解释我在哪里弄错了吗?

Could someone explain to me where I'm getting it wrong?

推荐答案

应该删除cookie,因为您将cookie的生存期设置为0。

The cookie should be deleted, because you set his lifetime to 0.

也许在那里仍在运行Firefox进程,请查看任务管理器。

Maybe there is still a firefox-process running, take a look into the taskmanager.

这篇关于关闭浏览器时,会话cookie会过期吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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