title: codeigniter session only work for one page not for other pages linked to the page
body: <p>I have login with username and password to the page it will login successfull and that page has link for other pages but i am setting username to session variable but it will say session is not availabe.</p>
  
  <pre><code>    verifylogin.php
  
      &lt;?php 
  
  class VerifyLogin extends CI_Controller {
  
  
  
   function __construct()
   {
     parent::__construct();
     $this-&gt;load-&gt;model('login/user','',TRUE);
   }
  
   function index()
   {
     //This method will have the credentials validation
     $this-&gt;load-&gt;library('form_validation');
  
     $this-&gt;form_validation-&gt;set_rules('username', 'Username', 'trim|required|xss_clean');
     $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');
  
     if($this-&gt;form_validation-&gt;run() == FALSE)
     {
       //Field validation failed.&amp;nbsp; User redirected to login page
  
       $this-&gt;load-&gt;view('index');
  
     }
     else
     {
        //$this-&gt;load-&gt;view('home_view');
       //Go to private area
       $password = $this-&gt;input-&gt;post('password');
       if($this-&gt;check_data($password))
       {
       redirect('login_f/home', 'refresh');
       }
       else
       {
           $data['username'] = $this-&gt;input-&gt;post('username');
           $data['rannum'] = $this-&gt;send_confirm_email();      
           $this-&gt;load-&gt;view('/login/verify_code2',$data);
       }
     }
  
   }
  
   function check_database($password)
   {
     //Field validation succeeded.&amp;nbsp; Validate against database
     $username = $this-&gt;input-&gt;post('username');
     $this-&gt;load-&gt;model('login/user');
  
  
     //query the database
     $result = $this-&gt;user-&gt;login($username, $password);
     $value = $this-&gt;user-&gt;user_type($username);
  
  
     if($result)
     {
  
  
       if($value == 0)
       {  
           $sess_array = array();
           foreach($result as $row)
           {
             $sess_array = array(
               //'id' =&gt; $row-&gt;id,
               'username' =&gt; $row-&gt;username
             );
             $this-&gt;session-&gt;set_userdata('logged_in', $sess_array);
           }
           return TRUE;
       }
  
  
     }
     else
     {
       $this-&gt;form_validation-&gt;set_message('check_database', 'Invalid username or password');
       return false;
     }
   }
  
      function check()
      {
          $this-&gt;load-&gt;view('index');
      }
  
  
  
  
  
  }
  ?&gt;
  
  home.php
  
  
  &lt;?php 
  session_start(); //we need to call PHP's session object to access it through CI
  class Home extends CI_Controller {
  
   function __construct()
   {
     parent::__construct();
   }
  
   function index()
   {
     if($this-&gt;session-&gt;userdata('logged_in'))
     {
       $session_data = $this-&gt;session-&gt;userdata('logged_in');
       $data['username'] = $session_data['username'];
       $this-&gt;load-&gt;view('login/home_view', $data);
     }
     else
     {
       //If no session, redirect to login page
  
  
       redirect('login_f/login', 'refresh');
  
  
     }
   }
  
   function logout()
   {
     $this-&gt;session-&gt;unset_userdata('logged_in');
     session_destroy();
     redirect('login_f/home', 'refresh');
   }
  
  }
  
  ?&gt;
  </code></pre>