think\Cookie::init PHP Method

init() public static method

Cookie初始化
public static init ( array $config = [] ) : void
$config array
return void
    public static function init(array $config = [])
    {
        if (empty($config)) {
            $config = Config::get('cookie');
        }
        self::$config = array_merge(self::$config, array_change_key_case($config));
        if (!empty(self::$config['httponly'])) {
            ini_set('session.cookie_httponly', 1);
        }
        self::$init = true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Cookie管理
  * @param string|array  $name cookie名称,如果为数组表示进行cookie设置
  * @param mixed         $value cookie值
  * @param mixed         $option 参数
  * @return mixed
  */
 function cookie($name, $value = '', $option = null)
 {
     if (is_array($name)) {
         // 初始化
         Cookie::init($name);
     } elseif (is_null($name)) {
         // 清除
         Cookie::clear($value);
     } elseif ('' === $value) {
         // 获取
         return 0 === strpos($name, '?') ? Cookie::has(substr($name, 1), $option) : Cookie::get($name);
     } elseif (is_null($value)) {
         // 删除
         return Cookie::delete($name);
     } else {
         // 设置
         return Cookie::set($name, $value, $option);
     }
 }
All Usage Examples Of think\Cookie::init