title: sessions and cookies lifetime
body: <p>when we use the line session_start() there are two possibilities:
  1. we are starting a new session (this method works via a cookie that the default for the expire time of it is zero, when the session ends)
  2. we are continuing a current session.</p>
  
  <p>in addition, if we use in one of the php files the function session_set_cookie_params($lifetime); that allows us to change the expire time of the session's cookie.</p>
  
  <p>my question is if we then write in another php file before the session starts the session_set_cookie_params($lifetime); does it updates the session's cookie to expire for another $lifetime seconds?? (because usually when setting a cookie again it updates the cookie)</p>
  
  <p>here are some php files that demonstrates what I'm trying to ask:</p>
  
  <p>the first file:</p>
  
  <pre><code>&lt;?php
  $lifetime=30;
  session_set_cookie_params($lifetime);
  
  session_start();
  
  $_SESSION["username"] = "kobe" ;
  
  ?&gt;
  </code></pre>
  
  <p>the second file:</p>
  
  <pre><code>    &lt;?php
  $lifetime=30;
  session_set_cookie_params($lifetime);
  
  session_start();
  
  
  echo "Username = " . $_SESSION["username"];
  
  ?&gt;
  </code></pre>
  
  <p>after accessing the first file the session is supposed to end after 30 seconds. if I will acess the second file before the 30 seconds will it update the cookie to live for another 30 seconds?? if not can you explain why??? </p>
  
  <p>edit: from what I have examined I learned that the server sends a response to the browser to build the session's cookie only when the session is first initialized. now the only lifetime parameter that will be used is in the first file that the user will acess. <strong>and from then the session will restart every lifetime seconds</strong>?? is this right???</p>
  
  <p>to demonstrate: lets say the user access the first file that says to build a session cookie that will last 30 seconds. then he aceesses the second file, the line where it says that the lifetime is 30 seconds will be ignored, the count until the session ends is from where we first accessed the first file. after that 30 seconds it will start to count another 30 seconds and then kill the session again, and then again...
  is this right???</p>