Пример #1
0
 public function testGet()
 {
     $cubex = new Cubex();
     $request = new Request([], [], [], ['ckey' => 'cookie']);
     $cubex->instance('request', $request);
     $app = Cookie::getFacadeApplication();
     Cookie::setFacadeApplication($cubex);
     $this->assertEquals('cookie', Cookie::get('ckey'));
     $this->assertEquals('default', Cookie::get('cs', 'default'));
     Cookie::setFacadeApplication($app);
 }
Пример #2
0
 /**
  * Retrieve the user from the cookie
  *
  * @param bool $checkQueue
  *
  * @return IAuthedUser|null
  */
 public function getCookieUser($checkQueue = true)
 {
     $cookied = Cookie::get($this->getCookieName(), null, $checkQueue);
     if ($cookied !== null) {
         $authedUser = $this->getCubex()->make('\\Cubex\\Auth\\AuthedUser');
         if ($authedUser instanceof IAuthedUser) {
             try {
                 $authedUser->unserialize($cookied);
                 return $authedUser;
             } catch (\Exception $e) {
             }
         }
     }
     return null;
 }