title: PHP sessions in HTACCESS - timeout
body: <p>I'm debugging a infinite loop problem in PHP in my "logout" routine.</p>
  
  <pre><code>if($_SESSION)
  {
      session_unset();
      session_destroy();
  }
  sleep(1);
  header('7location: http://accounts.DOMAIN.com/');
  exit;
  </code></pre>
  
  <p>in my main / initial.inc.php script i have :-</p>
  
  <pre><code>$sess=0;
  $sess=$_SESSION['loggedin'];
  foreach($_SESSION as $asw =&gt; $asd)
  {
      $logrep.="SESSW '$asw' '$asd'\n";
  }
  
  if($sess&gt;0)
  {
      if($sess&lt;$ty)
      {
          $logrep.="is timed out - logging out\n";
          header('Location: http://accounts.DOMAIN.com/logout/');
          exit;
  </code></pre>
  
  <p>Theres a bit more code which i've taken out - but in my 'logout' script Ive got DESTROY / UNSET etc - </p>
  
  <p>but when it redirects to my inward script, my sessions STILL EXIST ? - &amp; then it determines i'm timed out, &amp; redirects to my logout routine.</p>
  
  <p>QUERY: is there a fool-proof way to remove / eliminate ALL sessions ?</p>
  
  <p>QUERY :-</p>
  
  <pre><code>$previous_name = session_name("NAME");
  session_save_path("$directory");
  session_start();
  </code></pre>
  
  <p>Is there a php.ini line i can use, to replace  session_name  so that all/any PHP scripts are using the same name ? (just in case there are some scripts not using the named session.)</p>
  
  <p>EDIT :-</p>
  
  <p>If i use </p>
  
  <pre><code>    session_unset();
      session_destroy();
  </code></pre>
  
  <p>will it destroy <em>ALL</em> sessions ? or just the currently-named one ? (I suspect some of my scripts aren't using the named session)</p>
  
  <p>Ps - scripts are in different directories / subdomains.</p>
  
  <p>EDIT 2 :-</p>
  
  <p>Ive now chanmged my script to :-</p>
  
  <pre><code>     $sess=0;
       $logrep.="SESS NOW '$sess'\n";
       $logrep.=var_dump( $sess=$_SESSION['loggedin']);
       $logrep.="SESSNOW2 - '$sess'\n\n\n";
       $text.="Logged in time $sess\n";
       $logrep.="\nSESS = $sess\n";
       $temp2=time();
       $temp1=($sess-$temp2);
       $logrep.="IFF SESS $sess &gt; TIME $time - TEMP $temp1\n";
       if($sess&gt;0)
       {
         - redirect to log out routine .... 
  </code></pre>
  
  <p>(some code removed)</p>
  
  <p>RESULT :-</p>
  
  <pre><code>    OLD SESS - '1391680203'
      SESS NOW '0'
      SESSNOW2 - '1391680203'
  </code></pre>
  
  <p>Apparently, my sessions are NOT being deleted / removed.</p>