コード例 #1
0
ファイル: SessionTest.php プロジェクト: seytar/psx
 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
ファイル: Container.php プロジェクト: visapi/amun
 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
ファイル: DefaultContainer.php プロジェクト: seytar/psx
 /**
  * @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
ファイル: User.php プロジェクト: visapi/amun
 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;
 }