Page 1 of 1

Retrieving the session variable

Posted: Sat Aug 30, 2003 11:57 am
by ngfrancisco
Hi!

I have been trying to solve my problem on session but no to avail. My problem is that the session that I have set on a page is not visible on another page.

// noname1.php
session_start();
if ( !session_is_registered("userID") )
{
session_register("userID");
$userID = 25;
}

After submitting the page to another page

// noname2.php
session_start();
print("User ID: " . $userID . "<br>");

There's no value on $userID. I have look to many books already and documentation regarding the session and my implementation is the same with them. And I can't think of anything already why it doesn't work on my PC. I was able to setup the apache and php successfully. I have tried this on Windows 2000 and Windows XP home and result is the same.

I hope you guys can give me some points or help that I might have missed.

Thanks a lot in advance. :)

Posted: Sat Aug 30, 2003 12:06 pm
by jayr517
This is how I do it...

Code: Select all

// noname1.php 
session_start(); 
$_SESSION&#1111;'userid'] = 25;
Then to retrieve on another page...

Code: Select all

After submitting the page to another page 

// noname2.php 
session_start(); 
print("User ID: " . $_SESSION&#1111;'userid'] . "<br>");
Hope that helps.