Welcome Guest, Not a member yet? Register   Sign In
Code Igniter Session problem
#30

[eluser]WanWizard[/eluser]
All session solutions require proper configuration, and proper understanding of the cookie mechanism.

Most of the problems reported fall in the first category, a problem which is becoming bigger now that modern browsers implement a stricter enforcement of the cookie RFC. For example, you will see that browsers that enforce this RFC, will reject cookies with hostname 'localhost'. Also empty domains, or domains like ".com" will be rejected, and hostnames and/or domains that don't match the host/domain in the URL.

Second thing to understand is that sessions are implemented using a cookie. The cookie is sent to the browser in the HTTP header of the server reponse, and contains (at least) the session_id. When a new request to that same server is made, the cookie is sent back to the server in the HTTP header, where it is picked up by the application, which matches the session_id from the cookie with session data in whatever server side storage mechanism is chosen.

Knowing this, you have to be careful with anything that interferes with the normal request/response flow. In particular, redirects. A redirect interrupts the server response, which in some situations causes the cookie not to be send to the browser.
If this happens when the browser already has a valid cookie, there is no issue. If this happens when it's a new session, or when CI has just rotated the session_id (which by default happens every 300 seconds), you have an issue, because the session_id on the server doesn't match what you have on the client.

You have a similar issue with Ajax calls. The response of an Ajax call doesn't include a cookie. So if CI decides that it's time to rotate the session_id on an Ajax call, again the session_id on the server is updated, but the cookie in the browser still has the old session_id. So at the next page request, no valid session is found.

And then there are server side bugs. One well known one concerns IIS up to version 7, which deletes cookies from the HTTP header if that same header contains a "Location" redirect.

Also some browsers appear not to process/store cookies if the HTTP header contains a "Location" redirect.


Messages In This Thread
Code Igniter Session problem - by El Forum - 10-22-2007, 08:29 AM
Code Igniter Session problem - by El Forum - 10-22-2007, 09:42 AM
Code Igniter Session problem - by El Forum - 10-22-2007, 10:05 AM
Code Igniter Session problem - by El Forum - 10-23-2007, 12:12 AM
Code Igniter Session problem - by El Forum - 10-23-2007, 02:34 AM
Code Igniter Session problem - by El Forum - 11-07-2007, 07:31 PM
Code Igniter Session problem - by El Forum - 11-22-2007, 09:18 AM
Code Igniter Session problem - by El Forum - 11-22-2007, 12:29 PM
Code Igniter Session problem - by El Forum - 11-24-2007, 08:26 PM
Code Igniter Session problem - by El Forum - 11-24-2007, 08:45 PM
Code Igniter Session problem - by El Forum - 11-24-2007, 09:33 PM
Code Igniter Session problem - by El Forum - 11-25-2007, 03:56 AM
Code Igniter Session problem - by El Forum - 11-25-2007, 08:12 AM
Code Igniter Session problem - by El Forum - 02-26-2008, 08:46 AM
Code Igniter Session problem - by El Forum - 02-26-2008, 12:42 PM
Code Igniter Session problem - by El Forum - 04-21-2008, 10:11 PM
Code Igniter Session problem - by El Forum - 04-28-2008, 03:48 PM
Code Igniter Session problem - by El Forum - 05-20-2008, 12:16 PM
Code Igniter Session problem - by El Forum - 08-01-2008, 03:38 PM
Code Igniter Session problem - by El Forum - 09-16-2008, 11:44 AM
Code Igniter Session problem - by El Forum - 07-31-2009, 01:59 PM
Code Igniter Session problem - by El Forum - 08-27-2009, 05:20 PM
Code Igniter Session problem - by El Forum - 10-17-2009, 12:28 AM
Code Igniter Session problem - by El Forum - 11-30-2009, 09:06 PM
Code Igniter Session problem - by El Forum - 01-18-2010, 11:47 PM
Code Igniter Session problem - by El Forum - 03-02-2010, 09:34 AM
Code Igniter Session problem - by El Forum - 10-05-2010, 05:30 AM
Code Igniter Session problem - by El Forum - 10-05-2010, 08:16 AM
Code Igniter Session problem - by El Forum - 10-06-2010, 08:20 AM
Code Igniter Session problem - by El Forum - 10-06-2010, 09:12 AM
Code Igniter Session problem - by El Forum - 10-09-2010, 11:04 AM
Code Igniter Session problem - by El Forum - 10-25-2010, 08:52 AM
Code Igniter Session problem - by El Forum - 11-03-2010, 03:47 AM
Code Igniter Session problem - by El Forum - 11-03-2010, 10:32 AM
Code Igniter Session problem - by El Forum - 11-18-2010, 01:05 PM
Code Igniter Session problem - by El Forum - 11-18-2010, 01:45 PM
Code Igniter Session problem - by El Forum - 11-18-2010, 02:06 PM
Code Igniter Session problem - by El Forum - 11-18-2010, 03:52 PM
Code Igniter Session problem - by El Forum - 01-18-2011, 04:40 AM
Code Igniter Session problem - by El Forum - 01-20-2011, 03:14 AM
Code Igniter Session problem - by El Forum - 04-30-2011, 07:05 PM
Code Igniter Session problem - by El Forum - 04-30-2011, 11:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB