Пример #1
0
 public function testGetter()
 {
     $this->assertEquals('psx_session', $this->sess->getName());
     $this->assertEquals('PSX\\Session', $this->sess->getSessionTokenKey());
     // token is always the same since we are on CLI and have no user agent
     // or remote ip
     $this->assertEquals('876d2e7b380ea3c9567ef09df11c7926', $this->sess->getToken());
 }
Пример #2
0
 public function getSession()
 {
     $session = new Session($this->getParameter('session.name'));
     if ($this->hasParameter('session.id')) {
         $session->setId($this->getParameter('session.id'));
     }
     $session->start();
     return $session;
 }
Пример #3
0
 /**
  * @return \PSX\Session
  */
 public function getSession()
 {
     $name = $this->hasParameter('session.name') ? $this->getParameter('session.name') : 'psx';
     $session = new Session($name);
     if (PHP_SAPI != 'cli') {
         $session->start();
     }
     return $session;
 }
Пример #4
0
 public static function findUserId(Session $session, Registry $registry)
 {
     $id = $session->get('amun_id');
     $lastSeen = $session->get('amun_t');
     $aId = $registry['core.anonymous_user'];
     if ($aId === false) {
         throw new Exception('Unknown anonymous user');
     } else {
         $aId = intval($aId);
     }
     if ($id !== false && $lastSeen !== false) {
         $now = time();
         $expire = $registry['core.session_expire'];
         if ($now - $lastSeen > $expire) {
             $id = $aId;
         } else {
             $session->set('amun_t', time());
         }
     } else {
         $id = $aId;
     }
     return $id;
 }