Session data lost between redirects - 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 data lost between redirects (/showthread.php?tid=38333) |
Session data lost between redirects - El Forum - 02-05-2011 [eluser]Kobus M[/eluser] Hi, This is driving me insane, and I don't know what is causing the problem. I have posted a brief note on someone else's post that has a very similar problem, but there is no responses there, and perhaps mine is not 100% the same as his problem. I am using CodeIgniter 1.7.2 (didn't upgrade yet, not sure I am seeing a need to do so yet, as I am still struggling to learn CI). I wrote a little controller that handles login functionality for me, that records login attempts, failed attempts, last login information, etc. etc. etc., and after a successful login, I use redirect('controller/method') to change to the appropriate controller once login is successful. Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in. Is there a better way to preserve session data than with a redirect? I saw a few post of people using flashdata to do this, but my attempts at that were fruitless. Could anybody please shed some light on what I am doing wrong, please? Kobus Session data lost between redirects - El Forum - 02-05-2011 [eluser]Kobus M[/eluser] Before someone jumps on my back for not providing full information. It seems that people are quick to do that here. CI version: 1.72 Custom libraries: NONE Sessions config: Code: $config['sess_cookie_name'] = 'admaxsession'; I tried various options. encryption, no encryption. Database, no database, upped the expiration and time to update settings. All possible options in the settings above that I could fathom, and still not working. I have also followed advice on more than 8 topics with concrete solutions for similar problems here, none solving my problem. Thanks! Kobus Session data lost between redirects - El Forum - 02-05-2011 [eluser]toopay[/eluser] [quote author="Kobus M" date="1296914389"] Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in.[/quote] How you can identify, that session variables are lost? You dont forgot to load session library, before try to retrieve session data, right? Session data lost between redirects - El Forum - 02-05-2011 [eluser]toopay[/eluser] just simple test, change your config to this : Code: $config['sess_expiration'] =0; Session data lost between redirects - El Forum - 02-05-2011 [eluser]InsiteFX[/eluser] If your running Internet Explorer go into Ie Internet options and check your cookie restrictions! InsiteFX Session data lost between redirects - El Forum - 02-05-2011 [eluser]Kobus M[/eluser] [quote author="toopay" date="1296924908"][quote author="Kobus M" date="1296914389"] Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in.[/quote] How you can identify, that session variables are lost? You dont forgot to load session library, before try to retrieve session data, right?[/quote] My session library is loaded in my config file by default. To test, I loaded the library even in each controller's index function. Still does not resolve. How do I know the session variables are being lost? I log sessions in the database, and here is what I see: 1. Every page load, there is a new session ID. 2. Every page load, the user_data fields are blank for that page load's entry. Is there something else I am missing? Kobus Session data lost between redirects - El Forum - 02-05-2011 [eluser]Kobus M[/eluser] [quote author="toopay" date="1296924908"][quote author="Kobus M" date="1296914389"] Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in.[/quote] How you can identify, that session variables are lost? You dont forgot to load session library, before try to retrieve session data, right?[/quote] Thanks for the response! I tried what you said, no success. Kobus Session data lost between redirects - El Forum - 02-05-2011 [eluser]Kobus M[/eluser] [quote author="toopay" date="1296925336"]just simple test, change your config to this : Code: $config['sess_expiration'] =0; Thanks for the response. It does not make any difference. Have a great day! Kobus Session data lost between redirects - El Forum - 02-05-2011 [eluser]arbme666[/eluser] Just an idea... do you redirect to another directory? If so the probem may lie in you cookie settings in config.php. You may have the cookie locked to a certain directory so when you redirect to a different one the cookie is not sent thus having no session data. config.php Code: $config['cookie_domain'] = '.example.com'; Make sure you have a trailing forward slash for cookie path and a fullstop in front of the domain. |