Sessions - Not Working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Sessions - Not Working (/showthread.php?tid=62262) |
RE: Sessions - Not Working [SOLVED] - Narf - 06-29-2015 There's no way to disable the locking, but that shouldn't be a problem for AJAX requests ... they just won't be really asynchronous. Other than the redirect happening before the login request is executed, I can't think of a reason why the session would be empty. RE: [SOLVED] Sessions - Not Working - iD30 - 07-02-2015 (06-29-2015, 03:18 AM)Narf Wrote: There's no way to disable the locking, but that shouldn't be a problem for AJAX requests ... they just won't be really asynchronous. Other than the redirect happening before the login request is executed, I can't think of a reason why the session would be empty. @Narf: I have narrowed it down to what it loosing the session, I have tried a couple of options to prevent this from happen with some Stackoverflow help howevere nothing seems to be working so I thought I would see if you have any input on this. Basically on login, because use's an ajax request, after the login is successful it redirects to the dashboard, the session is fully populated with the data need until I redirect, the way I have set it up and because its using AJAX is to redirect with Code: public function redirect($Uri, $Send301Header = false) In this instance it is using the ELSE clause of the if/else which is where the session becomes reset. Thoughts? RE: Sessions - Not Working - Narf - 07-03-2015 Yep ... unless you call session_write_close() prior to doing that redirect, the session cookie is never sent to the browser, because you've already started the output and you can no longer send a header. That's why you shouldn't directly echo from a controller/model/library and always use the views instead. RE: Sessions - Not Working - iD30 - 07-03-2015 (07-03-2015, 01:34 AM)Narf Wrote: Yep ... unless you call session_write_close() prior to doing that redirect, the session cookie is never sent to the browser, because you've already started the output and you can no longer send a header. That's why you shouldn't directly echo from a controller/model/library and always use the views instead. Cheers Narf, more or less the same as what solutions are on the web, after trying the Code: session_write_close() Will look a bit deeper see if I can get it to work. Thanks RE: Sessions - Not Working - mike7418 - 11-14-2015 (06-25-2015, 10:34 AM)Wouter60 Wrote: You are wrong about loading the session as a driver. I'm trying to use sessions in database on v 3.01 and it is not working. I am getting the error A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE `id` = '79a66a6e1e7cb4dcb58794a078629cc5532f2e6b'' at line 2 SELECT `data` WHERE `id` = '79a66a6e1e7cb4dcb58794a078629cc5532f2e6b' Filename: libraries/Session/drivers/Session_database_driver.php Line Number: 160 I am using mysqli RE: Sessions - Not Working - sv3tli0 - 11-15-2015 (11-14-2015, 12:29 PM)mike7418 Wrote: I'm trying to use sessions in database on v 3.01 and it is not working. I am getting the error at config.php there is description just before session configuration: Quote:sess_save_path: At the moment you haven't set its name and for that reason there is NO FROM .. in you session DB queries .. RE: Sessions - Not Working - mike7418 - 11-15-2015 (11-15-2015, 02:26 AM)sv3tli0 Wrote:(11-14-2015, 12:29 PM)mike7418 Wrote: I'm trying to use sessions in database on v 3.01 and it is not working. I am getting the error RE: Sessions - Not Working - jvandemerwe - 11-25-2015 @iD30: I am using sessions as well. I have autoloaded the 'session' in the libraries in the autoLoad.php. The difference I have is that I have: $config['sess_save_path'] = $_SERVER['DOCUMENT_ROOT'] . '/session_cache'; in the config.php. For the rest I am doing the same thing as you do and it is working fine. |