From c4123537efcb1ddfdfdd68690b45f680744b53f4 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 23 May 2016 16:03:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BCookie=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 20 ++++++++++++++++++++ library/think/Cookie.php | 3 +++ 2 files changed, 23 insertions(+) diff --git a/convention.php b/convention.php index 8e2f20a1..d958784b 100644 --- a/convention.php +++ b/convention.php @@ -167,6 +167,26 @@ return [ 'auto_start' => true, ], + // +---------------------------------------------------------------------- + // | Cookie设置 + // +---------------------------------------------------------------------- + 'cookie' => [ + // cookie 名称前缀 + 'prefix' => '', + // cookie 保存时间 + 'expire' => 0, + // cookie 保存路径 + 'path' => '/', + // cookie 有效域名 + 'domain' => '', + // cookie 启用安全传输 + 'secure' => false, + // httponly设置 + 'httponly' => '', + // 是否使用 setcookie + 'setcookie' => true, + ], + // +---------------------------------------------------------------------- // | 数据库设置 // +---------------------------------------------------------------------- diff --git a/library/think/Cookie.php b/library/think/Cookie.php index 167df72f..3ca1a0e6 100644 --- a/library/think/Cookie.php +++ b/library/think/Cookie.php @@ -37,6 +37,9 @@ class Cookie */ public static function init(array $config = []) { + if (empty($config)) { + $config = Config::get('session'); + } self::$config = array_merge(self::$config, array_change_key_case($config)); if (!empty(self::$config['httponly'])) { ini_set('session.cookie_httponly', 1);