Remember Username & Password

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webgenius
    New Member
    • Apr 2007
    • 15

    #1

    Remember Username & Password

    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_nu m_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.ph p"
    session_start() ;
    session_registe r("myusername") ;
    session_registe r("mypassword") ;
    $_SESSION['loginname'] = $myusername;
    //echo $_session['loginname'];
    header("locatio n:index.php");
    }[/PHP]

    I'm using <?php echo $_session['loginname']; in index.php. Is there anything wrong with the code?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    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.

    Comment

    • webgenius
      New Member
      • Apr 2007
      • 15

      #3
      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.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

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

        Ronald

        Comment

        • webgenius
          New Member
          • Apr 2007
          • 15

          #5
          problem solved. Had used $_session instead of $_SESSION. Didn't know it was case-sensitive.

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            Good you found that out yourself. See you around.

            Ronald

            Comment

            Working...