Esempio n. 1
0
 public function testGetSet()
 {
     $this->assertEquals(false, isset($_SESSION['foo']));
     $this->assertEquals(false, $this->sess->get('foo'));
     $this->assertEquals(false, $this->sess->has('foo'));
     $this->sess->set('foo', 'bar');
     $this->assertEquals(true, isset($_SESSION['foo']));
     $this->assertEquals('bar', $_SESSION['foo']);
     $this->assertEquals('bar', $this->sess->get('foo'));
     $this->assertEquals(true, $this->sess->has('foo'));
 }
Esempio n. 2
0
File: User.php Progetto: 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;
 }