Exemple #1
0
 protected function dispatch()
 {
     $name = $this->getName();
     if (isset($_COOKIE[$name]) && ($sessionId = $_COOKIE[$name])) {
         $this->setId($sessionId);
     } else {
         if (!isset($_COOKIE[$name])) {
             setcookie($name, $this->getId(), time() + 60 * $this->config['lifetime'], $this->config['path'], $this->config['domain'], $this->config['secure'], $this->config['http_only']);
         }
     }
     parent::start();
     register_shutdown_function([$this, 'save']);
 }
 /**
  * Called by workerman application<br>
  * 检验凭证。 参数是凭证数据。如果检验通过,请返回用户ID;否则返回false
  * @param $credential
  * @return bool|integer
  */
 public function validateCredential($credential)
 {
     list($sessionId, $token) = $credential;
     $sessionId = \Crypt::decrypt($sessionId);
     $token = \Crypt::decrypt($token);
     $sessStore = new Store($sessionId, \App::make('session')->driver()->getHandler(), $sessionId);
     $sessStore->start();
     if ($sessStore->has($this->tokenKey)) {
         if ($sessStore->get($this->tokenKey) == $token) {
             $sessStore->remove($this->tokenKey);
             $userIdKey = 'login_' . md5('Illuminate\\Auth\\Guard');
             $userId = $sessStore->get($userIdKey);
             return $userId;
         }
     }
     return false;
 }
Exemple #3
0
 /**
  * Starts the session storage.
  *
  * @return bool True if session started.
  * @throws \RuntimeException If session fails to start.
  * @static 
  */
 public static function start()
 {
     return \Illuminate\Session\Store::start();
 }
 /**
  * {@inheritdoc}
  */
 public function start()
 {
     $this->store->start();
     return $this;
 }
Exemple #5
0
 protected function createStorage($sessionId = null)
 {
     if ($sessionId !== null) {
         // $name = '/Google_Client';
         // $path = session_save_path().'/'.$name;
         $name = 'Recca0120Socialite';
         $path = sys_get_temp_dir() . '/' . $name;
         $sessionId = sha1(serialize($sessionId));
         $file = new Filesystem();
         if ($file->isDirectory($path) === false) {
             $file->makeDirectory($path, 0755, true);
         }
         $handler = new FileSessionHandler($file, $path);
         $session = new LaravelSession($name, $handler, $sessionId);
         // $handler = new SymfonyFileHandler($path);
         // $session = new SymfonySession($handler);
         $session->setId($sessionId);
         $session->start();
         $this->saveSessionWhenShutdown($session);
     } else {
         $session = static::$session;
         if ($session === null) {
             $session = $this->request->getSession();
             if ($session === null) {
                 if (session_status() == PHP_SESSION_NONE) {
                     $handler = new SymfonyNativeSessionHandler();
                 } else {
                     $handler = new SymfonyPhpBridgeSessionHandler();
                 }
                 $session = new SymfonySession($handler);
                 $session->start();
                 $this->saveSessionWhenShutdown($session);
             }
             static::$session = $session;
         }
     }
     $storage = new Storage($session);
     return $storage;
 }
Exemple #6
0
 function let(Store $session)
 {
     $session->start();
     $this->beConstructedWith($session);
 }