php - Trouble with session variables
19
I'm trying to set a 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?
Answer
Solution:
Rather than:
Use:
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.
Answer
Solution:
On the second page, you'll need to say
Answer
Solution:
You need to do the following on page 2:
You also need to use $_SESSION, not $_session