Enabling hooks makes session timeout/destory *updated* - 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: Enabling hooks makes session timeout/destory *updated* (/showthread.php?tid=54559) |
Enabling hooks makes session timeout/destory *updated* - El Forum - 09-14-2012 [eluser]esset[/eluser] I have a very very strange behaviour which I'm unsure if it's even like this - but it's my feeling this is the case. 1. I have a basic login system. In my "MY_Controller" I check to see if the user is logged in using: Code: function is_logged_in() This works fine and I can be logged in for quite some time before I get logged out due to me not doing anything (inactivity). 2. I now enable "Hooks" and I have one hook that runs "post_controller". 3. I can now only idle for 3-4 mins on the site before that IF-statement runs and kicks the user out the site. How odd is this? Any ideas what can be wrong? Thank you so much Enabling hooks makes session timeout/destory *updated* - El Forum - 09-14-2012 [eluser]esset[/eluser] I'm now 100% sure this is some sort of bug. When I turn $config['hooks'] to TRUE my session dies or destroys after 3-4 minutes. If I don't use hooks it'll live for hours. Does anyone have any ideas? Here's my hooks.php file: Code: $hook['post_controller'] = array( Here's my tracker.php file: Code: class Tracker extends MY_Controller { Enabling hooks makes session timeout/destory *updated* - El Forum - 09-17-2012 [eluser]rogierb[/eluser] I dont think its a bug. Your using an extension to My_Controller which is an extension to CI_Controller. This might be the problem. It looks like this is creating a new object and a new session As far as I kno the hooks get processed outside the CI superobject (see core/CodeIgniter.php). If you want to use the superobject you need to use $this->CI = get_instance(); I would do something like: Code: class Tracker { This way your staying inside the original CI object and not creating a new one when extending the class Enabling hooks makes session timeout/destory *updated* - El Forum - 09-17-2012 [eluser]esset[/eluser] Thank you for the tip! I'll try it straight away Will let you know |