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

Why session_id cannot get the value of session

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-06 13:53:11
Original
1568 people have browsed it

Set session

<code>     $sid=session_id();
     session('uid',100);</code>
Copy after login
Copy after login

It can be set up successfully here.

Get session

<code>  session_id($sid);
  session_start();
  session('uid');//无法获取值</code>
Copy after login
Copy after login

Reply content:

Set session

<code>     $sid=session_id();
     session('uid',100);</code>
Copy after login
Copy after login

It can be set up successfully here.

Get session

<code>  session_id($sid);
  session_start();
  session('uid');//无法获取值</code>
Copy after login
Copy after login

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;

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template