From 2955e89f3daa804dc70577a8342cab07633911c7 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 12 Mar 2016 18:07:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bsession=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E8=B5=8B?= =?UTF-8?q?=E5=80=BC=E6=93=8D=E4=BD=9C=20=E4=BF=AE=E6=AD=A3response?= =?UTF-8?q?=E7=B1=BBsuccess=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 10 +++++----- library/think/Response.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helper.php b/helper.php index 7543fcce..bedb39f8 100644 --- a/helper.php +++ b/helper.php @@ -200,7 +200,7 @@ function U($url = '', $vars = '', $suffix = true, $domain = false) return \think\Url::build($url, $vars, $suffix, $domain); } -function session($name, $value = '') +function session($name, $value = '', $prefix = null) { if (is_array($name)) { // 初始化 @@ -209,14 +209,14 @@ function session($name, $value = '') // 清除 \think\Session::clear($value); } elseif ('' === $value) { - // 获取 - return \think\Session::get($name); + // 判断或获取 + return 0 === strpos($name, '?') ? \think\Session::has(substr($name, 1), $prefix) : \think\Session::get($name, $prefix); } elseif (is_null($value)) { // 删除session - return \think\Session::delete($name); + return \think\Session::delete($name, $prefix); } else { // 设置session - return \think\Session::set($name, $value); + return \think\Session::set($name, $value, $prefix); } } diff --git a/library/think/Response.php b/library/think/Response.php index 4f985948..cdb32bce 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -174,7 +174,7 @@ class Response 'code' => $code, 'msg' => $msg, 'data' => $data, - 'url' => is_null($url) ? $_SERVER["HTTP_REFERER"] : $url, + 'url' => is_null($url) && isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $url, 'wait' => $wait, ];