Home >Backend Development >PHP Tutorial >Why session_id cannot get the value of session

Why session_id cannot get the value of session

WBOY
WBOYOriginal
2016-07-06 13:53:111549browse

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>

Reply content:

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;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn