webgenius Posted March 15, 2008 Share Posted March 15, 2008 At present I'm using $_SESSION['UserName'] to create and store the login details. But I'm not able to access this session variable. Is there any way for the website to remember these details? $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "LoginOK.php" session_start(); session_register("myusername"); session_register("mypassword"); $_SESSION['loginname'] = $myusername; //echo $_session['loginname']; header("location:index.php"); } I'm using <?php echo $_session['loginname']; in index.php. Is there anything wrong with the code? Quote Link to comment Share on other sites More sharing options...
ikmyer Posted March 15, 2008 Share Posted March 15, 2008 not sure if $_session['loginname'] is case sensitve... but try accessing it by $_SESSION['loginname'] Also, you have to have session_start(); on each page you want to access the $_SESSION Quote Link to comment Share on other sites More sharing options...
dotBz Posted March 15, 2008 Share Posted March 15, 2008 hmm. yeah, and put it on the very top of the script.. Quote Link to comment Share on other sites More sharing options...
webgenius Posted March 15, 2008 Author Share Posted March 15, 2008 not sure if $_session['loginname'] is case sensitve... but try accessing it by $_SESSION['loginname'] Also, you have to have session_start(); on each page you want to access the $_SESSION Problem solved. It was just the wrong usage of $_session, as you said. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.