English 中文(简体)
当浏览器关闭时不会过期的会话
原标题:session not expiring when browser closes

我有一些 $_SESSION 变量来跟踪用户的页面。 这样, 我就可以让错误信息更加具体, 网络应用程序更方便用户。 如果用户不来自任何页面, 应该在主页的顶端有一个“ 欢迎” 信息。 但是, 当我关闭浏览器并访问主页时, 我就会收到与会议闭幕前链接的页面对应的信息。 这就是我的功能 :

function come_from($from_page, $updates_occurred) { 
    $message = "";
    if ($updates_occurred == false) {
        $message .= "Welcome to the User List.<br/>";
        $message .= "Select the user you wish to update, or add a new user. ";
    } elseif ($from_page == "edit_user.php") {
        $message .= "The user was successfully updated";
    } else { 
        $message .= "The user was successfully added";
    }
return $message; 
}

在主页顶部,我有以下代码:

if (isset($_SESSION[ updates_occurred ])) {
    $updates_occurred = $_SESSION[ updates_occurred ];
} else {
    $updates_occurred = false;
}

if (isset($_SESSION[ come_from ])) {
    $come_from = $_SESSION[ come_from ];
} else {
    $come_from = NULL;
    echo "got here";
}


echo come_from($come_from, $updates_occurred); 

* 最新更新仅记录用户是否成功编辑/添加到上一页。

我猜我主要关心的是:我使用会话变量的方式有问题吗?如果我的理解是正确的,会话变量应该在浏览器关闭时过期,对吗?

最佳回答

关闭浏览器标签不关闭会话

您应该关闭整个浏览器以关闭会话

问题回答

暂无回答




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签