问题描述:

First Page :

<?php

session_start();

$_SESSION["username"]="skygao";

echo $_SESSION["username"];

after run this script on first page, O/P is:

skygao

Second Page :

<?php

session_start();

var_dump($_SESSION["username"]);

I am trying to get value on second Page, but O/P is:

NULL

Can anyone help me?

PHP5.4.45 + Nginx1.8 + CentOS6.5

php.ini session info:

网友答案:

You are starting session on the second page, hence you were unable to get those values,

use

if(!isset($_SESSION)){
     session_start();
}

on your second page.

相关阅读:
Top