Why call session not working? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9) +--- Thread: Why call session not working? (/showthread.php?tid=72323) |
Why call session not working? - garimapatil - 12-05-2018 my config is like this : Code: $config['sess_driver'] = 'database'; // select database driver My autoload is like this : Code: $autoload['libraries'] = array('database', 'session', 'form_validation', 'functions'); In controller login.php : Code: $this->session->set_userdata('club', 'chelsea'); In controller dashboard.php : Code: echo $this->session->userdata('club'); It did not succeed in calling the session club if a different controller But, when I call session club in the same controller(controller login.php), it's working I try Code: $this->library->load('session'); in the constructor of Code: Dashboard.php . But it's not a success Any solution to solve my problem? Thank you RE: Why call session not working? - php_rocs - 12-05-2018 @garimapatil Instead of this... PHP Code: echo $this->session->userdata('club');// [Technically this should work.] Try this... PHP Code: echo $this->session->club; Documentation: https://codeigniter.com/user_guide/libraries/sessions.html?highlight=session#retrieving-session-data Are you using any debugging tools? Also, keep in mind that the login page must be executed first in order for the session variable to be set. If the dashboard page is executed first then the session variable will not exist. RE: Why call session not working? - dave friend - 12-05-2018 (12-05-2018, 10:40 AM)php_rocs Wrote: Try this... Based on the config items I think the OP is using a CI version < 3.0 and so your suggestion of $this->session->club; won't work. RE: Why call session not working? - php_rocs - 12-06-2018 @garimapatil, What version of CI are you using? |