Session information being lost
<p>I'm running a login script and according to who logs in I redirect to one of two pages</p>

<p>If I direct to a page that is in a directory below the main directory all works fine, however if i direct to a page that is above the directory in which the index.php file sits, the session information seems to be lost and the user is asked to login again</p>

<p>I know that I could simply place the second page in a directory below the main directory but I would like to understand if it is possible to maintain the session information when directing to a page above the main directory </p>

<p>the user goes to a page called login.html, when they have input there information, they are sent to login.php, it is here where the redirect occurs </p>

<pre><code>if ($username==$dbusername&amp;&amp;$password==$dbpassoword)
{
    if($admin == "1"){
        header('location: http://www.edit.domain_name.co.uk/');
        $_SESSION['username']=$username;
        $_SESSION['id']=$id;

    }else{
        header('location: /member');
        $_SESSION['username']=$username;
        $_SESSION['id']=$id;
    }
}
</code></pre>

<p>I have put <code>session_start ();</code> at the beginning of every page where the user would need to login to access. Any input would be greatly received</p>

<p>the full code for the login script is </p>

<pre><code>&lt;?php
session_start () ;

$username = $_POST['username'] ;
$password = $_POST['password'] ;

################# ADMIN OR NOT   ###################################################

include_once "mysql/global.php";
$result = mysql_query("SELECT admin FROM users WHERE username = '$username'");
if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
}


$row = mysql_fetch_row($result);

$admin = $row[0];


################# ###############################################################

if ($username&amp;&amp;$password)
{

include "mysql/global.php";

$query = mysql_query("SELECT * FROM users WHERE username='$username'") ;

$numrows = mysql_num_rows($query) ;

if ($numrows!=0)
{

  while ($row = mysql_fetch_assoc($query) )
  {
      $dbusername = $row['username'] ;
      $dbpassoword = $row["password"] ;

  }

  // check to see if they match!
  if ($username==$dbusername&amp;&amp;$password==$dbpassoword)
  {
      if($admin == "1"){
          session_start();
          header('location: http://www.edit.domin_name.co.uk/admin');
          $_SESSION['username']=$username;
          $_SESSION['id']=$id;

      }else{
      session_start();
      header('location: /member');
      $_SESSION['username']=$username;
      $_SESSION['id']=$id;


      }
  }
  else 
      echo "&lt;center&gt;incorrect password!&lt;/center&gt;" ;

}
else
    die ("&lt;center&gt;That user does not exist!&lt;/center&gt;") ;


}
else
    echo ("&lt;center&gt;Please enter a username and password&lt;/center&gt;&lt;br/&gt;") ;
    die ("&lt;a href=\"index.php\"&gt;&lt;center&gt;&lt;b&gt;Click here to try again&lt;/b&gt;&lt;/center&gt;&lt;/font&gt;");


    ?&gt;
</code></pre>
