title: PHP: How to store session in cookie
body: <p>I am new to PHP and am currently struggling with the following: </p>
  
  <p><strong>I have a login page where I start a session as below which works well so far.</strong> </p>
  
  <pre><code>session_start();
  // ...
  $_SESSION["Customer"]["username"] = $username;
  $_SESSION["Customer"]["email"] = $email;
  </code></pre>
  
  <p>Now I have never used sessions before but assume they die once a user closes their browser and I would like to keep them logged in so that they don't have to do this whenever they re-enter the page. 
  My thought was to use a cookie for that but I am not sure how I can store my session in a cookie. </p>
  
  <p>I did some research on this and came across the following but <strong>I am not sure if that's the right approach and how to use it for what I need</strong>.<br>
  Can someone help me with this ?</p>
  
  <pre><code>session_set_cookie_params ( int $lifetime [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]] );
  </code></pre>
  
  <p><code>lifetime</code> in my case would be indefinite so as long as possible,<br>
  <code>path</code> would probably just be "/",<br>
  <code>secure</code> would be true<br>
  and I wouldn't need the <code>httponly</code>. </p>
  
  <p>Many thanks in advance, 
  Mike</p>