From abe0ea0783228746b6b3239bdb8b0bf4a6d37d6b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 14 Sep 2016 16:05:43 +0800 Subject: [PATCH] =?UTF-8?q?Session=E7=B1=BB=E5=A2=9E=E5=8A=A0pull=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=94=A8=E4=BA=8E=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=B9=B6=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Session.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/library/think/Session.php b/library/think/Session.php index d9d927ec..e8f56fd9 100644 --- a/library/think/Session.php +++ b/library/think/Session.php @@ -178,6 +178,23 @@ class Session return $value; } + /** + * session获取并删除 + * @param string $name session名称 + * @param string|null $prefix 作用域(前缀) + * @return mixed + */ + public static function pull($name, $prefix = null) + { + $result = self::get($name, $prefix); + if ($result) { + self::delete($name, $prefix); + return $result; + } else { + return null; + } + } + /** * 删除session数据 * @param string $name session名称