Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP会话设置为变量并取消设置。_Php_Session_Cakephp - Fatal编程技术网

PHP会话设置为变量并取消设置。

PHP会话设置为变量并取消设置。,php,session,cakephp,Php,Session,Cakephp,只是一个简单的问题 我尝试将会话存储到变量中,然后在第二行中尝试取消设置会话。在我的变量变为空之后 //Assuming session Hello has a value already $hello_world = $this->Session->read('Hello'); $this->Session->delete('Hello'); print_r($hello_world); //empty here where it shouldn't ... 您正

只是一个简单的问题

我尝试将会话存储到变量中,然后在第二行中尝试取消设置会话。在我的变量变为空之后

//Assuming session Hello has a value already

$hello_world = $this->Session->read('Hello');
$this->Session->delete('Hello');

print_r($hello_world); //empty here where it shouldn't ...

您正在使用删除会话变量

$this->Session->delete('Hello');

因此,名为
Hello
的会话变量将从会话中删除。请参见此

尝试回显该变量,因为它不是数组。如果不起作用,那么你必须发布你的整个视图。

我想,他想知道“为什么$hello\u world是空的”,而不是如何取消会话变量。啊,我的错误,重定向到404时,我以为会话已经结束了。我真傻。