title: How to pass session information to a subdirectory in php
body: <p>I'm creating a simple website in PHP that users can log into.</p>
  
  <p>All pages in the root directory work fine, but when I try and start a session on a web page in a subdirectory it doesn't read it </p>
  
  <p>This is what I have at the start of the web pages in the subdirectory, which as I say works fine for every page in the root directory - </p>
  
  <pre><code>session_start();
  if(!session_is_registered(myusername)){
  header("location: http://www.four-corners.org.uk/welcome.php");
  </code></pre>
  
  <p>several people seem to have the same problem but I've not found a solution yet</p>
  
  <p><strong>Edit -</strong></p>
  
  <p>Below is the code I've used to define 'myusername' and register it in the session </p>
  
  <pre><code>// Define $myusername and $mypassword 
  $myusername=$_POST['myusername']; 
  $mypassword=md5($_POST['mypassword']);
  
  // Register $myusername, $mypassword and redirect to file "login_success.php"
  session_register("myusername");
  session_register("mypassword"); 
  </code></pre>