Connecting Tech Pros Worldwide Help | Site Map

Remember Username & Password

Newbie
 
Join Date: Apr 2007
Posts: 15
#1: Mar 15 '08
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?

[PHP]$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");
}[/PHP]

I'm using <?php echo $_session['loginname']; in index.php. Is there anything wrong with the code?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Mar 15 '08

re: Remember Username & Password


Like was said in your last post: if you dont start the session on index.php you weill not be able to retrieve the session variables.
Newbie
 
Join Date: Apr 2007
Posts: 15
#3: Mar 15 '08

re: Remember Username & Password


Quote:

Originally Posted by markusn00b

Like was said in your last post: if you dont start the session on index.php you weill not be able to retrieve the session variables.

I've started the session in all the pages now. Still it doesn't work.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#4: Mar 16 '08

re: Remember Username & Password


What makes you so sure that [php]if($count==1){[/code] return true?

Ronald
Newbie
 
Join Date: Apr 2007
Posts: 15
#5: Mar 16 '08

re: Remember Username & Password


problem solved. Had used $_session instead of $_SESSION. Didn't know it was case-sensitive.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#6: Mar 16 '08

re: Remember Username & Password


Good you found that out yourself. See you around.

Ronald
Reply