title: Pass the login details to another page using session PHP
body: <p>I need the  login details in another page for retrieving the data from the database. Basically, I need to display the editable form with the details of the user logged in. I tried <code>session_register()</code> for storing the username in login.php page. But for some reason I am not able to display the username using <code>$_SESSION[]</code> in my edit.php page. I am doing this after the function <code>session_start()</code> as well.</p>
  
  <p>I am new to php, so don't know whether I misunderstood session! Or is there any other way to pass the login details?</p>
  
  <p>Thanks in advance</p>
  
  <p>My code:</p>
  
  <pre><code>**Login.php**
        &lt;?php
         $userName = $_POST['username'];
        $password = $_POST['password'];
        //Connect to the database
        //query the database
          if($rows==1)
         {
        session_start();
         $_SESSION['user']=$userName;
       header("location:edit_user.php");
       }
        else
        {
       echo 'Data Does Not Match &lt;br /&gt; Re-Enter UserName and Password';
       }
       ?&gt;
  
  **In edit.php**
      &lt;?php
      session_start();
      if(!isset($_SESSION['user']))
     {
      header("location:login_form.php");
     }
     else
     {
      echo $_SESSION['user'];
      }
      ?&gt;
  </code></pre>