Esempio n. 1
0
 public static function isValid($token)
 {
     $session = SomeFactory::getSession();
     $csrftoken = $session->get('csrftoken', 'sadfasgagsagsadfsaf');
     // time is not used $csrftokentime = $session->get('csrftokentime',0);
     if ($csrftoken === $token) {
         return true;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * send location header to browser.
  * @param string $url the http address to redirect browser
  * @param string $msg the optional message, not implemented
  */
 public function redirect($url, $msg = '')
 {
     // if message is not empty, save it to session
     if (!empty($msg)) {
         $session = SomeFactory::getSession();
         $session->set('sysmessage', $msg);
     }
     header('Location:' . $url);
     $this->close();
 }
Esempio n. 3
0
 public static function getUser()
 {
     //if the user is in session, get from there, else create empty user. and put that to session.
     $session = SomeFactory::getSession();
     $user = $session->get('someuser', null);
     if (!$user) {
         $user = new SomeUser();
         $session->set('someuser', $user);
     }
     return $user;
 }