php - What are the available ways to check session's value throughout the website? -


in default controller session's value set. in every controller calls different view, wants check if session's value set view shown otherwise redirect user log in view.
so, per knowledge have check session's value in every controller there shortcut way?? or there way call 1 file/function called every time before call of controller. can check session's value there.
had try via hook :

class authentication extends ci_hooks {      var $ci;      function __construct() {         $this->ci = & get_instance();     }      public function verify_session() {          if (!isset($this->ci->session)) {             $this->ci->load->library('session');             $user_session_id = $ci->session->userdata('email');              if ($user_session_id == '') {                 redirect('common_controller/home_controller');             }         }     }  } 

but shows me eroor : severity: notice

message: trying property of non-object

filename: hooks/authentication.php

line number: 20

you don't framework you're using, i'm guessing if you're using mvc there single php file (usually index.php) can put code.

also appears use hooks add hook executed before controller identified , called.

just remember add check if you're on login page , not apply redirect if so...


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -