title: Session is not set after redirect in codeigniter
body: <p>I've created a project in Codeigniter. My problem is when I log in, auth controller shows the value that is set in session $this->session->userdata("logged_in") but it is not redirecting to dashboard.</p>
  
  <p>I also changed the PHP version on the live server from <code>PHP 7.1</code> to <code>PHP 5.6</code> but it's still not working. Session works perfectly on local server with xampp but not working on live server</p>
  
  <p><strong>Auth_model</strong></p>
  
  <pre><code>  public function Authentification() {
      $notif = array();
      $email = $this-&gt;input-&gt;post('email',TRUE);
      $password = Utils::hash('sha1', $this-&gt;input-&gt;post('password'), AUTH_SALT);
  
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('users');
      $this-&gt;db-&gt;where('email', $email);
      $this-&gt;db-&gt;where('password', $password);
      $this-&gt;db-&gt;limit(1);
  
      $query = $this-&gt;db-&gt;get();
  
      if ($query-&gt;num_rows() == 1) {
          $row = $query-&gt;row();
          if ($row-&gt;is_active != 1) {
              $notif['message'] = 'Your account is disabled !';
              $notif['type'] = 'warning';
          } else {
              $sess_data = array(
                  'users_id' =&gt; $row-&gt;users_id,
                  'first_name' =&gt; $row-&gt;first_name,
                  'email' =&gt; $row-&gt;email
              );
             $this-&gt;session-&gt;set_userdata('logged_in', $sess_data);
  
          }
      } else {
          $notif['message'] = 'Username or password incorrect !';
          $notif['type'] = 'danger';
      }
  
      return $notif;
  }
  </code></pre>
  
  <p><strong>Auth controller</strong></p>
  
  <pre><code> class Auth extends CI_Controller {
  
  function __construct() {
      parent::__construct();
  
      Utils::no_cache();
      if ($this-&gt;session-&gt;userdata('logged_in')) {
          redirect(base_url('dashboard'));
          exit;
      }
  }
  
  
  
  public function index() {
          redirect(base_url('home'));
      }
  
   public function login() {
      $data['title'] = 'Login';
      $this-&gt;load-&gt;model('auth_model');
  
      if (count($_POST)) {
          $this-&gt;load-&gt;helper('security');
          $this-&gt;form_validation-&gt;set_rules('email', 'Email address', 'trim|required|valid_email|xss_clean');
          $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'trim|required|xss_clean');
  
          if ($this-&gt;form_validation-&gt;run() == false) {
              // $data['notif']['message'] = validation_errors();
              // $data['notif']['type'] = 'danger';
                $status = validation_errors();
               if ( $this-&gt;input-&gt;is_ajax_request() ) {
                  echo json_encode($status);
                  exit;
              }
          } 
          else {
              $data['notif'] = $this-&gt;auth_model-&gt;Authentification();
                    //  it show the result here but not redirect to dashboard
               //    print_r($this-&gt;session-&gt;userdata("logged_in"));
          //         die("auth/login");
          }
      }
  
  
      if ($this-&gt;session-&gt;userdata('logged_in')) {
          redirect(base_url('dashboard'));
          exit;
      }
  
      /*
       * Load view
       */
      $this-&gt;load-&gt;view('includes/header', $data);
      $this-&gt;load-&gt;view('home/index');
      $this-&gt;load-&gt;view('includes/footer');
  }
  </code></pre>
  
  <p><strong>dashboard</strong></p>
  
  <pre><code>  class Dashboard extends CI_Controller {
  
  var $session_user;
  
  function __construct() {
      parent::__construct();
        $this-&gt;load-&gt;model('auth_model');
       $this-&gt;load-&gt;helper('tool_helper');
  
      Utils::no_cache();
      if (!$this-&gt;session-&gt;userdata('logged_in')) {
          redirect(base_url('home'));
          exit;
      }
      $this-&gt;session_user = $this-&gt;session-&gt;userdata('logged_in');
  
  }
  
  /*
   * 
   */
  
  public function index() {
      $data['title'] = 'Dashboard';
      $data['session_user'] = $this-&gt;session_user;
      // print_r($this-&gt;session-&gt;userdata("logged_in")); //its show empty
      $data['items'] = $this-&gt;auth_model-&gt;get_all_products();
  
      $this-&gt;load-&gt;view('includes/header', $data);
      // $this-&gt;load-&gt;view('includes/navbar');
      $this-&gt;load-&gt;view('includes/navbar_new');
      $this-&gt;load-&gt;view('dashboard/index');
      $this-&gt;load-&gt;view('includes/footer');
  }
  </code></pre>
  
  <p>I don't know why session not set. I have been stuck in this for a week. Please help me out.</p>