开发者

Trouble with session variables

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜