userIsLoggedIn() public static method

Checks if the user is logged in or not
public static userIsLoggedIn ( ) : boolean
return boolean user's login status
Example #1
0
 public static function checkNoAutentication()
 {
     // No es necesario la inicialización de la sesión pero es una comprobación más
     Session::init();
     if (Session::userIsLoggedIn()) {
         header('location: /');
         exit;
     }
 }
 function __construct()
 {
     Session::init();
     Auth::checkSessionConcurrency();
     if (!Session::userIsLoggedIn() && Request::cookie('remember_me')) {
         Redirect::to("login/loginWithCookie");
     }
     $this->view = new View();
 }
 /**
  * Check if there is concurrent session, and logout if so, redirect to home and hard-stop.
  */
 public static function checkSessionConcurrency()
 {
     if (Session::userIsLoggedIn()) {
         if (Session::concurrentSessionsExist()) {
             LoginModel::logout();
             Redirect::home();
             exit;
         }
     }
 }
Example #4
0
 public static function checkStudentAuthentication()
 {
     Session::init();
     // self::checkSessionConcurrency();
     if (!Session::userIsLoggedIn() || Session::get("user_account_type") < 1) {
         Session::destroy();
         header('location: ' . Config::Get('URL') . 'login');
         exit;
     }
 }
Example #5
0
 /**
  * Detects if there is concurrent session (i.e. another user logged in with the same current user credentials),
  * If so, then logout.
  */
 public static function checkSessionConcurrency()
 {
     if (Session::userIsLoggedIn()) {
         if (Session::isConcurrentSessionExists()) {
             \Huge\Model\LoginModel::logout();
             Redirect::home();
             Application::stop();
         }
     }
 }
Example #6
0
 /**
  * Construct the (base) controller. This happens when a real controller is constructed, like in
  * the constructor of IndexController when it says: parent::__construct();
  */
 function __construct()
 {
     // always initialize a session
     Session::init();
     // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
     if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
         header('location: ' . Config::get('URL') . 'login/loginWithCookie');
     }
     // create a view object to be able to use it inside a controller, like $this->View->render();
     $this->View = new View();
 }
Example #7
0
 public static function checkAutentication()
 {
     Session::init();
     if (!Session::userIsLoggedIn()) {
         Session::destroy();
         Session::init();
         Session::set('origen', $_SERVER['REQUEST_URI']);
         header('location: /Login');
         exit;
     }
 }
Example #8
0
 public static function checkAuth()
 {
     Session::init();
     if (!Session::userIsLoggedIn()) {
         Session::destroy();
         header('location: ' . Config::get('URL') . '/login?redirect=' . urlencode($_SERVER['REQUEST_URI']));
         // to prevent fetching views via cURL (which "ignores" the header-redirect above) I leave the application
         // the hard way, via exit(). @see https://github.com/panique/php-login/issues/453
         // this is not optimal and will be fixed in future releases
         exit;
     }
 }
Example #9
0
 /**
  * Construct the (base) controller. This happens when a real controller is constructed, like in
  * the constructor of IndexController when it says: parent::__construct();
  */
 function __construct()
 {
     // always initialize a session
     Session::init();
     // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
     if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
         header('location: ' . Config::get('URL') . 'login/loginWithCookie');
     }
     // create a view object to be able to use it inside a controller, like $this->View->render();
     $this->View = new View();
     $this->Must = new MustView(array('loader' => new Mustache_Loader_FilesystemLoader(Config::get('PATH_VIEW'), ['extension' => '.html']), 'partials_loader' => new Mustache_Loader_FilesystemLoader(Config::get('PATH_PARTIAL'), ['extension' => '.html']), 'cache' => Config::get('PATH_TEMPLATES_CACHE'), 'logger' => new MustacheLogger(Mustache_Logger::DEBUG)));
 }
Example #10
0
 public static function checkAuthentication()
 {
     // initialize the session (if not initialized yet)
     Session::init();
     // if user is not logged in...
     if (!Session::userIsLoggedIn()) {
         // ... then treat user as "not logged in", destroy session, redirect to login page
         Session::destroy();
         header('location: ' . Config::get('URL') . 'login');
         // to prevent fetching views via cURL (which "ignores" the header-redirect above) we leave the application
         // the hard way, via exit(). @see https://github.com/panique/php-login/issues/453
         // this is not optimal and will be fixed in future releases
         exit;
     }
 }
 function __construct()
 {
     // always initialize a session
     Session::init();
     // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature)
     if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) {
         header('location: ' . Config::get('URL') . 'login/loginWithCookie');
     }
     /**
      *
      * add in Twig or use the Static Function
      * if use the Static method this is not needed here
      *
      * */
     Twig_Autoloader::register();
     $this->loader = new Twig_Loader_Filesystem(VIEW_DIR);
     $this->twig = new Twig_Environment($this->loader, array('cache' => APP_DIR . '/cache', 'debug' => true, 'auto_reload' => true, 'strict_variables' => true, 'autoescape' => true));
     /**
      * the View is no longer needed
      */
     // create a view object to be able to use it inside a controller, like $this->View->render();
     //$this->View = new View();
 }
 /**
  * @return bool
  */
 public static function isUserLoggedIn() : bool
 {
     return Session::userIsLoggedIn();
 }
Example #13
0
        echo ' class="active" ';
    }
    ?>
 >
          <a href="<?php 
    echo Config::get('URL');
    ?>
login/logout">Logout</a>
        </li>
      <?php 
}
?>
    </ul>

    <?php 
if (Session::userIsLoggedIn()) {
    ?>
      <div class="panel panel-header">
<!--        Logged in as: <?php 
    echo Session::get("user_name");
    ?>
, Table Number = <?php 
    echo Session::get("table_number");
    ?>
 -->
        Logged in as: <?php 
    echo Session::get("user_name");
    ?>
, Table Number =
        <?php 
    $val = Session::get("table_number");
Example #14
0
 public static function userIsAdmin()
 {
     if (!self::$initialized) {
         self::initialize();
     }
     return Session::userIsLoggedIn() && Session::get('user_account_type') === '2';
 }
Example #15
0
 public static function isLoggedIn()
 {
     return Session::userIsLoggedIn();
 }