title: PHP week cookies gone in few hours
body: <p>I have the following html markup for login form:</p>
  
  <pre><code>&lt;form name="login" id="login" method="post" action="login_action.php"&gt;
      &lt;div id="inp_usr"&gt;&lt;input type="text" name="username" id="username" /&gt;&lt;/div&gt;
      &lt;div id="inp_pass"&gt;&lt;input type="password" name="password" id="password" /&gt;&lt;/div&gt;
      &lt;div id="rem_me"&gt;
          &lt;input type="hidden" name="remember" value="0" /&gt;
          &lt;input type="checkbox" name="remember" id="remember" value="1" checked /&gt;
          &lt;label for="remember" onclick=""&gt;&lt;/label&gt;
          &lt;span id="rem_me_t"&gt;Remember Me&lt;/span&gt;
      &lt;/div&gt;
      &lt;div id="inp_sub"&gt;&lt;input type="submit" id="log_sub" value="Login" /&gt;&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP code i am using for cookies:</p>
  
  <pre><code>$checkbox = '';
  if (isset($_POST['remember']))
  {
      $checkbox = 'remember_me';
  }
  
  $year = time() + 1209600;
  if($checkbox == 'remember_me')
  {
      setcookie('remember_me', $_POST['username'], $year);
  } elseif (!$_POST['remember']) {
      if (isset($_COOKIE['remember_me'])) {
          $past = time() - 100;
          setcookie(remember_me, gone, $past);
      }
  }
  </code></pre>
  
  <p>However while testing my website, i found out that if i am not visiting website for like a few hours, i am getting logged out. I am not really familiar with cookies so i dont know whats the problem in. Any help appreciated
  <hr>
  UPD: i changed the way i set cookies, but still getting logged out when restart browser:</p>
  
  <pre><code>$year = 315360000;
  $expiration = time() + $year;
  if($checkbox == 'remember_me')
  {
      setcookie('remember_me', $_POST['username'], $expiration);
  }
  </code></pre>