Sessions, not readable in constructor. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Sessions, not readable in constructor. (/showthread.php?tid=55931) |
Sessions, not readable in constructor. - El Forum - 11-17-2012 [eluser]Unknown[/eluser] Hi! I got a problem with sessions. The problem is that the sessions is not readable in a library constructor. My autoload: Code: $autoload['libraries'] = array( My Auth class (where the problem occurs): Code: public function __construct() My controller (where it works!): Code: class Users extends MY_Controller { So, why can't I get the session data in the constructor, but I can any time later in the code? It works in the Auth class if I put it later than the constructor. Like in the destructor. Sessions, not readable in constructor. - El Forum - 11-17-2012 [eluser]Mirge[/eluser] What happens when you: Code: print_r($this->_ci->session->all_sessiondata()); In the constructor? Sessions, not readable in constructor. - El Forum - 11-17-2012 [eluser]Unknown[/eluser] Oh, all_userdata() worked. My bad, ofc it was the config file that was not loaded! Thank you. Sessions, not readable in constructor. - El Forum - 11-17-2012 [eluser]Mirge[/eluser] Always something simple :o) |