Exemple #1
0
 /**
  * @return bool
  */
 protected function _destroy()
 {
     // Destroy the current session
     session_destroy();
     // Did destruction work?
     $status = !Base::getHttp()->sessionID();
     if ($status) {
         // Make sure the session cannot be restarted
         Cookie::delete($this->_name);
     }
     return $status;
 }
Exemple #2
0
 /**
  * 获取指定key的cookie值,否则返回默认值
  *
  * @param  string $key     cookie名
  * @param  mixed  $default 默认值
  * @return string
  */
 public static function get($key, $default = null)
 {
     if (!isset($_COOKIE[$key])) {
         return $default;
     }
     $cookie = $_COOKIE[$key];
     // 分离salt和内容
     $split = strlen(Cookie::salt($key, null));
     if (isset($cookie[$split]) && $cookie[$split] === '~') {
         list($hash, $value) = explode('~', $cookie, 2);
         if (Cookie::salt($key, $value) === $hash) {
             // 检查hash是否正确
             return $value;
         }
         // 不正确的话,那就删除cookie
         Cookie::delete($key);
     }
     return $default;
 }
Exemple #3
0
 /**
  * @return  bool
  */
 protected function _destroy()
 {
     return Cookie::delete($this->_name);
 }
Exemple #4
0
 /**
  * Completely destroy the current session.
  *     $success = $session->destroy();
  *
  * @return  boolean
  */
 public function destroy()
 {
     // Destroy the current session
     @session_destroy();
     // Did destruction work?
     $status = !session_id();
     if ($status) {
         // Make sure the session cannot be restarted
         Cookie::delete($this->_name);
     }
     return $status;
 }