Example #1
0
 /**
  * Set the value of a cookie.
  *
  * <code>
  *      // Set the value of the "favorite" cookie
  *      Cookie::put('favorite', 'Thin');
  *
  *      // Set the value of the "favorite" cookie for twenty minutes
  *      Cookie::put('favorite', 'Thin', 20);
  * </code>
  *
  * @param  string  $name
  * @param  string  $value
  * @param  int     $expiration
  * @param  string  $path
  * @param  string  $domain
  * @param  bool    $secure
  * @return void
  */
 public static function put($name, $value, $expiration = 0, $path = '/', $domain = null, $secure = false)
 {
     if ($expiration !== 0) {
         $expiration = time() + $expiration * 60;
     }
     $value = static::hash($value) . '+' . $value;
     // If the secure option is set to true, yet the request is not over HTTPS
     // we'll throw an exception to let the developer know that they are
     // attempting to send a secure cookie over the insecure HTTP.
     if ($secure && !Request::ssl()) {
         throw new Exception("Attempting to set secure cookie over HTTP.");
     }
     static::$jar[$name] = compact('name', 'value', 'expiration', 'path', 'domain', 'secure');
 }