コード例 #1
0
ファイル: Debug.class.php プロジェクト: Nozemi/MyFramework
 public static function isDebugUser()
 {
     if (!Session::isStarted()) {
         return false;
     }
     return Session::get('debug_user', true);
     // TODO: change this back to default to false
 }
コード例 #2
0
ファイル: Segment.php プロジェクト: andrescefe/SAPP
 /**
  *
  * Loads the segment only if the session has already been started, or if
  * a session is available (in which case it resumes the session first).
  *
  * @return bool
  *
  */
 protected function resumeSession()
 {
     if ($this->session->isStarted() || $this->session->resume()) {
         $this->load();
         return true;
     }
     return false;
 }
コード例 #3
0
 /**
  * prevent the session hijacking
  *
  * @param string $session_key Default is "PREVENT_SESSION_HIJACKING".
  * @param string $hashAlgo Is the Name of selected hashing algorithm (e.g. "md5", "sha256", "haval160,4", etc..).
  * @param int|string $exit Default is 1.
  */
 public static function preventHijacking($session_key = 'PREVENT_SESSION_HIJACKING', $hashAlgo = 'sha1', $exit = 1)
 {
     $hashData = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'];
     $hash = hash($hashAlgo, $hashData);
     if (Session::isStarted() && !Session::exists($session_key)) {
         Session::set($session_key, $hash);
     } elseif (Session::isStarted() || !Session::exists($session_key) || Session::get($session_key) != $hash) {
         exit($exit);
     }
 }
コード例 #4
0
 public function handleRequest(HttpRequest $request)
 {
     if (!Session::isStarted()) {
         Session::start();
     }
     if (!Session::get(Administrator::LABEL) instanceof Administrator && !$this->controller instanceof login) {
         Session::destroy();
         return ModelAndView::create()->setView('login');
     }
     return $this->controller->handleRequest($request);
 }
コード例 #5
0
 /**
  * @runInSeparateProcess
  */
 public function testClean()
 {
     Session::start();
     Session::set('test1', 'testing1');
     Session::set('test2', 'testing2');
     $this->assertTrue(Session::exists('test1'));
     $this->assertTrue(Session::exists('test2'));
     Session::clean();
     $this->assertTrue(Session::isStarted());
     $this->assertFalse(Session::exists('test1'));
     $this->assertFalse(Session::exists('test2'));
 }
コード例 #6
0
 public static function destroy()
 {
     if (!self::$isStarted) {
         throw new SessionNotStartedException();
     }
     self::$isStarted = false;
     try {
         session_destroy();
     } catch (BaseException $e) {
         // stfu
     }
     setcookie(session_name(), null, 0, '/');
 }
コード例 #7
0
 public function handleRequest(HttpRequest $request)
 {
     $form = Form::create()->add(Primitive::string('username')->setMax(64)->required())->add(Primitive::string('password')->addImportFilter(Filter::hash())->required())->import($request->getPost());
     if (!$form->getErrors()) {
         try {
             $admin = Administrator::dao()->logIn($form->getValue('username'), $form->getValue('password'));
         } catch (ObjectNotFoundException $e) {
             // failed to log in
             return ModelAndView::create()->setView('error');
         }
         if (!Session::isStarted()) {
             Session::start();
         }
         Session::assign(Administrator::LABEL, $admin);
         return ModelAndView::create()->setView(new RedirectToView('main'));
     }
     return ModelAndView::create()->setView('login');
 }
コード例 #8
0
ファイル: TestCase.php プロジェクト: nimbles/Framework
 /**
  * Gets a session
  * @param array $options
  * @return \Nimbles\Http\Session
  */
 public static function getSession($options = null)
 {
     $session = new Session($options);
     $session->isStarted(false);
     $session->setDelegate('session_start', array('\\Nimbles\\Http\\TestCase', 'sessionStart'));
     $session->setDelegate('session_id', array('\\Nimbles\\Http\\TestCase', 'sessionId'));
     $session->setDelegate('session_name', array('\\Nimbles\\Http\\TestCase', 'sessionName'));
     $session->setDelegate('session_regenerate_id', array('\\Nimbles\\Http\\TestCase', 'generateSessionId'));
     $session->setDelegate('session_destroy', array('\\Nimbles\\Http\\TestCase', 'sessionDestroy'));
     $session->setDelegate('headers_sent', array('\\Nimbles\\Http\\TestCase', 'isHeadersSent'));
     $session->setDelegate('setcookie', array('\\Nimbles\\Http\\TestCase', 'setcookie'));
     $session->setDelegate('setrawcookie', array('\\Nimbles\\Http\\TestCase', 'setrawcookie'));
     $session->setDelegate('readValue', array('\\Nimbles\\Http\\TestCase', 'readSession'));
     $session->setDelegate('writeValue', array('\\Nimbles\\Http\\TestCase', 'writeSession'));
     $session->setDelegate('clearValues', array('\\Nimbles\\Http\\TestCase', 'clearSession'));
     $session->setDelegate('offsetExists', array('\\Nimbles\\Http\\TestCase', 'sessionKeyExists'));
     return $session;
 }
コード例 #9
0
ファイル: NetteWebSessionTest.php プロジェクト: vrana/nette
 /**
  * Cleanup operations after each test method is run.
  * @return void
  */
 protected function tearDown()
 {
     if ($this->session->isStarted()) {
         $this->session->destroy();
     }
 }