title: PHP Session time out too fast
body: <p>I have a web page <code>index.php</code> it is a form that log a user into a session.</p>
  
  <pre><code>&lt;?php
  //start session
  session_start();
  unset($_SESSION['User']);
  session_destroy();  
  header('Content-Type: text/html; charset=UTF-8');
  
  //script that create a back door not relative for the question
  include("Controls/processBackDoor.php");
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
      //CSS, Javascript, meta tag, icon and title here
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="divWrapper"&gt;
          &lt;div id="divLogin"&gt;
              &lt;div id="divAnglais"&gt;
                  &lt;a href="EN/Index.php"&gt;English/Anglais&lt;/a&gt;
              &lt;/div&gt;
              &lt;form id="frmLogin" name="frmLogin" action="Controls/ProcessLogin.php" method="POST"&gt;
                  &lt;div id="divTextLogin"&gt;
                      &lt;ul id="textLogin" class="frmLogin"&gt;
                          &lt;li&gt;Nom d'utilisateur: &lt;/li&gt;
                          &lt;li&gt;&lt;/br&gt;&lt;/li&gt;
                          &lt;li&gt;Mot de passe: &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
                  &lt;div id="divInputLogin"&gt;
                      &lt;ul id="inputLogin" class="frmLogin"&gt;
                          &lt;li&gt;&lt;input type="text" id="txtUsername" name="txtUsername"/&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;/br&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;input type="password" id="txtPassword" name="txtPassword"/&gt;&lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
                  &lt;div id="divButtonLogin"&gt;
                      &lt;input type="submit" id="cmdLogin" class="cmdLogin" onmouseover="className='cmdLoginOver'" onmouseout="className='cmdLogin'" value="Connexion"/&gt;&lt;/br&gt;
                      &lt;?php
                      if(isset($_SESSION['msg']))
                      {
                          echo "&lt;div class='divLogin'&gt;".$_SESSION['msg']."&lt;/div&gt;";
                      }
                      ?&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So normal form. Here is the code that validate the user:</p>
  
  <pre><code>&lt;?php
  //resume session
  session_start();
  header('Content-Type: text/html; charset=UTF-8');
  //those are the classes used to connecte to the DB
  include("../Models/cConnexion.php");
  include("../Models/cConstanteConnexion.php");
  include("../Models/cUser.php");
  
  //Connexion
  $cn = new cConnexion($ConnexionWebHost, $ConnexionWebDBName, $ConnexionWebLogin, $ConnexionWebPassword);
  
  //reset session variables
  $_SESSION['User'] = null;
  $_SESSION['Group'] = null;
  $_SESSION['Site'] = null;
  
  if($cn-&gt;DBConnexion())
  {
  $user = array('username'=&gt;$_POST['txtUsername'], 'password'=&gt;$_POST['txtPassword']);
  $getUser = $cn-&gt;SecureSelect("SELECT 
                              us_username, us_password, us_firstName,
                              us_lastName, us_email
  
  FROM user 
                          WHERE BINARY us_username = :username 
                              AND BINARY us_password = :password", $user);
  
  if($getUser &lt;&gt; null)
  {
  
      while($User = $getUser-&gt;fetch())
      {
  
          $_SESSION['User'] = $User;
  
      }
  }
  
  if(isset($_SESSION['User']))
  {
      unset($_SESSION['msg']);
      header("Location: ../Pages/Accueil.php");
  }
  else
  {
      $_SESSION['msg'] = "Votre username ou votre mot de passe est invalide.";
      header("Location: ../Index.php");
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p>And finally I have this code on every other page to validate if the user was login. if he is not login he must be redirect to <code>index.php</code> so he can login.</p>
  
  <pre><code>if(!isset($_SESSION['User']) || $_SESSION['User'] == null)
  {
  header("Location: ../Index.php");
  }
  </code></pre>
  
  <p>The problem is that every time a change from page to page it redirect me to <code>index.php</code>.
  I was thinking maybe I unset the session somewhere else in the code but I check and it does'nt seems like it. </p>
  
  <p>Anyone have an idea on what cause the redirection?</p>