I am working on my register page.
I start the session at the top of my php file:
After form/data validation I create some session variables ($username comes from the HTML textbox and $insertedId comes from a select statement):Code:<?php // Lets start the session session_start();
Once sesssion variables are set I change locations to another php file:Code:// Lets set a few session variables $_SESSION['userName'] = $username; $_SESSION['userId'] = $insertedId;
Code:// Lets get out of here ... header("Location: home.php");
now, I am in home.php and I try to print my session variables:
Code:<?php echo "userName=". $_SESSION['userName']; echo "userId=". $_SESSION['userId']; ?>
This is the error message I get:
Notice: Undefined variable: _SESSION in C:\wamp\www\TheLastPick\home.php on line 45
userName=
Notice: Undefined variable: _SESSION in C:\wamp\www\TheLastPick\home.php on line 46
userId=
Any idea why my session variables aren't accessible in home.php?
Many thanks for any help.




Reply With Quote