Use thinkphp5.0 Session class,
dump(Session::get('id'));
What is the reason for the results printed here?
$id = input('get.id);
//第一次和id改变时进来
if(Session::get('id') != $id){
echo '新id';
}
Session::set('id',$id);
Supplement:
if($_SESSION['id] != $_GET['id])
{
echo '新id';
}
$_SESSION['id] = $_GET['id];
我现在的问题就是:id没有改变,但是一直都会走到 echo '新id' 这里,什么原因?
Print two sessions before assignment will have this result
Code:
Please describe the problem clearly
The values obtained by $_SESSION['id] and Session::get('id') are different. Because the Session class has a session prefix, what you get in $_SESSION['id] is not the value of Session::set('id',$id), so of course it will never wait.
It is not recommended to use the native $_SESSION in thinkphp