thinkphp5.0 session cannot be stored?
某草草
某草草 2017-05-16 13:00:00
0
3
636

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:

某草草
某草草

reply all(3)
淡淡烟草味

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.

Ty80

It is not recommended to use the native $_SESSION in thinkphp

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template