简体   繁体   English

PHP Session设置为变量并取消设置。

[英]PHP Session set into variable and unset it.

just a quick question. 只是一个简单的问题。

I'm trying to store a session into a variable and then in the second line I try to unset the session. 我正在尝试将会话存储到变量中,然后在第二行中尝试取消会话。 There after my variable become empty. 在我的变量变空之后。

//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 ...

You are deleting the session variable with 您正在删除会话变量

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

SO the session variable with name Hello will be deleted from the session.See this LINK 因此,将从会话中删除名为Hello的会话变量。请参阅此LINK

try to echo the variable since it is not an array. 尝试回显变量,因为它不是数组。 if doesn't work then u have to post your whole view. 如果不起作用,那么你必须张贴整个视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM