Exemple #1
0
 /**
  * 设置一个cookie
  *
  *     Cookie::set('theme', 'red');
  *
  * @param  string $name    cookie名
  * @param  string $value   cookie值
  * @param  int    $expired 生效时间(秒数)
  * @return bool
  */
 public static function set($name, $value, $expired = null)
 {
     // 处理过期时间
     if (null === $expired) {
         $expired = Cookie::$expiration;
     }
     if ($expired !== 0) {
         $expired += time();
     }
     // Add the salt to the cookie value
     $value = Cookie::salt($name, $value) . '~' . $value;
     return Base::getHttp()->setCookie($name, $value, $expired, Cookie::$path, Cookie::$domain, Cookie::$secure, Cookie::$httpOnly);
 }