开发者

Trouble with session variables

开发者 https://www.devze.com 2023-01-11 23:42 出处:网络
I\'m trying to set a 开发者_JS百科session variable and use it on another page. I have: pg1 session_start();

I'm trying to set a 开发者_JS百科session variable and use it on another page.

I have: pg1

session_start();
$_session['sessionID'] = $row['ID'];

Then on page two I have.

session_start();
$userID = $sessionID;

But when I use JC to alert this out I get nothing. Am I doing this wrong?


Rather than:

$userID = $sessionID;

Use:

$userID = $_SESSION['sessionID']

You need to specify the $_SESSION there because that is the array you stored the value in :)

Have a look at this session tutorial if you want.


On the second page, you'll need to say

$userID = $_SESSION['sessionID'];


You need to do the following on page 2:

session_start();
$userID = $_SESSION['sessionID'];

You also need to use $_SESSION, not $_session

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号