title: How do i make a token expire time
body: <p>I currently have functions to generate a token, but how would i go about making it expire?Also, what would be a good shelf-life for the token?</p>
  
  <p>Token Generation code:</p>
  
  <pre><code>function token($length = 40) {
      $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
      $charactersLength = strlen($characters);
      $token = 12000;
      $token = srand(floor(time() / $token));
      for ($i = 0; $i &lt; $length; $i++) {
          $token .= $characters[rand(0, $charactersLength - 1)];
      }
      return $token;
  }
  </code></pre>