Page 1 of 1

Remember Username & Password

Posted: Sat Mar 15, 2008 2:02 pm
by webgenius_coder
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?

Code: Select all

$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?

Re: Remember Username & Password

Posted: Sat Mar 15, 2008 3:26 pm
by Christopher
It needs to be:

Code: Select all

<?php
session_start();     // You must call this function before using $_SESSION. It loads the data into $_SESSION.
echo $_SESSION['loginname'];     // The name is all upper case

Re: Remember Username & Password

Posted: Sun Mar 16, 2008 2:22 am
by webgenius_coder
arborint wrote:It needs to be:

Code: Select all

<?php
session_start();     // You must call this function before using $_SESSION. It loads the data into $_SESSION.
echo $_SESSION['loginname'];     // The name is all upper case
Thanks. Problem solved.