Session undefined property in MY_Controller - 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: Session undefined property in MY_Controller (/showthread.php?tid=23956) |
Session undefined property in MY_Controller - El Forum - 10-27-2009 [eluser]Unknown[/eluser] Hi, I want to extend the controller with a login auth. I have to call a session for that but it crashes: Message: Undefined property: MY_Controller::$session Filename: libraries/MY_Controller.php Line Number: 22 Code: <?php if (! defined('BASEPATH')) exit('No direct script access allowed'); What am I doing wrong? The session class is being loaded in the autoload. I see a lot of examples online where it's no problem to extend the controller calling sessions in it, so I'm a bit confused. Thanks, L. Session undefined property in MY_Controller - El Forum - 10-27-2009 [eluser]imn.codeartist[/eluser] can you post your class where you extend your MY_Controller... what I am seeing is you haven't set the value in your session variable Code: $this->session->userdata('scheme_id') if CI don't find the variable it ouputs error. if your controller checks session value before Code: $this->session->set_userdata('scheme_id','some value') it outputs error. Session undefined property in MY_Controller - El Forum - 10-27-2009 [eluser]Unknown[/eluser] Thanks dixcoder. But I think that doesn't make any sense. If I set the userdata right before I check it, unfortunately it still errors on that undefined property... You need to use get_instance() to call the CI superclass as stated in the docs. But that doesn't solve the prob either. |