title: Perl CGI persistent cookies
body: <p>I want the user to non have to login even if the browser was closed. My cookies are set to expire after a month.</p>
  
  <p>when the user logs in sucessfully</p>
  
  <pre><code> $session = CGI::Session-&gt;new (undef, undef, {Directory=&gt;'tmp/'})
                                        or die CGI::Session-&gt;errstr;
                  $session-&gt;param('username', $username);
                  $session-&gt;expire('+1M');                
                  $cookie = $cgi-&gt;cookie( -name=&gt;$session-&gt;name, -value=&gt;$session-&gt;id );
                  print $cgi-&gt;header(-cookie=&gt;$cookie );
  </code></pre>
  
  <p>They are then redirected to another page that they can access as long as they don't close the browser. This is the code in the second page:</p>
  
  <pre><code>my $cookie = $cgi-&gt;cookie('CGISESSID');
  if ($cookie){
          print $cgi-&gt;header(-cookie =&gt; $cookie);
  else{
         //ask them to relog in
  }
  </code></pre>
  
  <p>I can see the sessions created in tmp/. How do I load an existing cookie after the browser is closed. How do I know which session to load based on the user/browser?</p>