delete() 공개 정적인 메소드

Cookie删除
public static delete ( string $name, string | null $prefix = null ) : mixed
$name string cookie名称
$prefix string | null cookie前缀
리턴 mixed
예제 #1
0
파일: Index.php 프로젝트: klsf/kldns
 public function logout()
 {
     Cookie::delete("userSid");
     if (!empty($this->userInfo)) {
         $this->pdo->execute("update pre_users set sid=:sid where uid=:uid limit 1", array(":uid" => $this->userInfo['uid'], ":sid" => getSid()));
     }
     header("Location:/");
 }
예제 #2
0
 public function testDelete()
 {
     $_COOKIE = ['a' => 'b', 'pre_abc' => 'c'];
     $this->assertEquals('b', \think\Cookie::get('a'));
     \think\Cookie::delete('a');
     $this->assertEquals(null, \think\Cookie::get('a'));
     $this->assertEquals('c', \think\Cookie::get('abc', 'pre_'));
     \think\Cookie::delete('abc', 'pre_');
     $this->assertEquals(null, \think\Cookie::get('abc', 'pre_'));
 }
예제 #3
0
파일: helper.php 프로젝트: yuhongjie/think
function cookie($name, $value = '')
{
    if (is_array($name)) {
        // 初始化
        \think\Cookie::init($name);
    } elseif (is_null($name)) {
        // 清除
        \think\Cookie::clear($value);
    } elseif ('' === $value) {
        // 获取
        return \think\Cookie::get($name);
    } elseif (is_null($value)) {
        // 删除session
        return \think\Cookie::delete($name);
    } else {
        // 设置session
        return \think\Cookie::set($name, $value);
    }
}
예제 #4
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);
     }
 }