Retrieving the session variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ngfrancisco
Forum Newbie
Posts: 2
Joined: Thu Aug 28, 2003 12:57 pm

Retrieving the session variable

Post 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. :)
jayr517
Forum Commoner
Posts: 26
Joined: Fri Aug 22, 2003 7:28 pm
Location: Boise, ID
Contact:

Post 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.
Post Reply