![]() |
Consistent set cookie failure - 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: Consistent set cookie failure (/showthread.php?tid=28575) |
Consistent set cookie failure - El Forum - 03-15-2010 [eluser]coolgeek[/eluser] I've been experiencing random session issues which I have determined are the result of the cookie not being set. The random nature of the issue has been enormously frustrating, but I have finally isolated a repeatable instance where my cookie is not being set. Some quick declarations based on prior research of the issue: - I am using the database for sessions - I have set my cookie domain (to the actual domain name, not mysite.com) - The problem occurs in both FF and IE My session and cookie configuration: Code: $config['sess_cookie_name'] = 'ci_session'; I've stripped down my offending controller to the following: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I had initially identified the problem as always occurring when both the flashdata and redirect statements were executed, but that the problem would not occur if I commented out either one of the two statements. Several threads indicate that this combination of flashdata/redirect can be problematic when not using a database to store sessions. I am in fact using a database to store sessions, so that does not seem to be my issue. With that as background, I am also using a couple of session overrides, the sources of which are specified in the function comments: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I was surprised to discover that the problem did not recur when I eliminated MY_Session.php. Subsequent research narrows the issue down to the _set_cookie function. So, to summarize, the problem only occurs when all three of the following steps are involved: - function _set_cookie is overriden, and - flashdata gets set, and - I redirect But the problem will not occur if I remove any one of the three steps is removed. (To be precise, I should state that the problem is not consistently repeatable when one of the steps is removed. Given the random occurrence of failure in setting cookies (from other controllers, as well as this one), that I noted at the beginning of the post, I cannot state definitively that the problem will never occur if I remove one of the steps.) I have compared the MY_Session._set_cookie function with the Session._set_cookie function and cannot see a problem. So does anybody have any ideas as to why my cookie isn't getting set? |