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? Link to comment https://forums.phpfreaks.com/topic/96306-remember-username-password/ 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 Link to comment https://forums.phpfreaks.com/topic/96306-remember-username-password/#findComment-492957 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.. Link to comment https://forums.phpfreaks.com/topic/96306-remember-username-password/#findComment-492960 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. Link to comment https://forums.phpfreaks.com/topic/96306-remember-username-password/#findComment-492971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.