codeigniter - Session keep track of whose logged in and only show to members -


i'm not sure when comes dealing session.

after log in , set session data.

how keep private pages show logged in.

do have run kind of validation views?

<?php  if($this->session->userdata('is_loggedin')!=1) {     redirect('kgindex/index','refresh'); }  ?> 

i'm not sure if correct, right messed code. functions don't work anymore.

where run session validations?

you want doing check in controller rather in view. example

class account extends ci_controller {      public function index()     {         if($this->session->userdata('is_loggedin')!=1)         {             redirect('kgindex/index','refresh');         }     } } 

if know every function in controller requires user logged in include check in __construct() function called whenever class accessed. therefore need put code in 1 place.

class account extends ci_controller {      public function __construct()     {         if($this->session->userdata('is_loggedin')!=1)         {             redirect('kgindex/index','refresh');         }     }      public function index()     {         //__construct() has been called     } } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -