销毁后PHP中的会话存在 [英] Sessions in PHP exists after Destroying

查看:27
本文介绍了销毁后PHP中的会话存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是学习 PHP 的新手.我创建了以下代码.

I am new to learning Php. I have created the following code.

<?php
/* 
 * Testing Sessions with PHP
 */
session_start();
$_SESSION['user_id'] = 'Testing User';
session_destroy();
?>

<html>
<head>
    <title> Sessions Page</title>
</head>
<body>
    <?php
       echo $_SESSION['user_id'];
    ?>
</body>
</html>

现在回声 $_SESSION['user_id'] 回声测试用户.我认为不应该,因为我已经破坏了会议.是什么原因?

Now the echo $_SESSION['user_id'] echos testing user. In my opinion it should not, as i have destroyed the session. what is the reason?

推荐答案

您需要取消设置会话变量.请参阅 http://php.net/manual/de/function.session-unset.php

You need to unset the session vars. See http://php.net/manual/de/function.session-unset.php

意思是,在销毁会话之前放置 session_unset().

Means, put session_unset() before you destroy the session.

这篇关于销毁后PHP中的会话存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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