isset() on codeigniter objects isset() on codeigniter objects codeigniter codeigniter

isset() on codeigniter objects


you don't need isset(); cause CI methods returns false or true

just do

 if($this->session->flashdata()){ }

and your error is cause you are surely not loading the session library:

so do this:

   $this->load->library('session');if($this->session->flashdata()){ }

if you prefer (i preferr) you can autoload the session library changing this in your config/autoload.php file:

$autoload['libraries'] = array('session');

so now you don't have to load anytime the session library cause CI autoloads that for you


You can check the existence of $this->session first

if (isset($this->session) && isset($this->session->flashdata('user_profile'))) {}


For proper validation you must do this method. Weather the values becomes NULL sometimes.

$sessusr=$this->session->userdata('username');  if(isset($sessusr) && trim($sessusr!='')) {//to do }