Home >Backend Development >PHP Tutorial >Why session_id cannot get the value of session
Set session
<code> $sid=session_id(); session('uid',100);</code>
It can be set up successfully here.
Get session
<code> session_id($sid); session_start(); session('uid');//无法获取值</code>
Set session
<code> $sid=session_id(); session('uid',100);</code>
It can be set up successfully here.
Get session
<code> session_id($sid); session_start(); session('uid');//无法获取值</code>
This is embarrassing
If you want to use session, you first need session_start(), and put it in front of all statements containing session;
Use $_SESSION['name'] = 'session' when setting and modifying;