当前位置: 动力学知识库 > 问答 > 编程问答 >

session - PHP can't get $_SESSION["xxx"] value on another Page?

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: