Welcome Guest, Not a member yet? Register   Sign In
Cookie not setting across controllers?
#1

[eluser]JCianflone[/eluser]
Hello,

I'm seeing something very strange happen and I'm not sure if I'm just doing something wrong with cookie setting or if this is a bug or what.

So here is the deal:

I have two controllers A and B...in the first controller (A), I'm checking for a cookie..that sets what city you're in...you can change that by clicking on a dropdown list and changing the city. That works perfectly fine. In controller A, there are three functions/pages...when you reset the cookie in any one of these functions, the result is returned correctly. If however, you click on a link that takes you to the other controller, the cookie value is not set. I have no idea why this is happening and since I normally don't work with cookies, I'm at a loss as to what the heck is happening.

Illustrative example:

site.com/a/p1 --- set cookie to 1
site.com/a/p2 --- set cookie to 2

go back to site.com/a/p1 --- cookie is set to 2 (correct value)
site.com/a/p3 -- cookie is correctly set to 2

site.com/b/p1 --- cookie is FALSE

I've tried this with both CI cookie helpers AND native setcookie and $_COOKIE functions the value in "b" is always wrong

wtf am I doing wrong here??
#2

[eluser]JCianflone[/eluser]
BAH! Nevermind. Everything was working correctly...except for the JS ReadCookie function I was using. Apparently it wasn't actually reading the cookie and was rewriting it instead.




Theme © iAndrew 2016 - Forum software by © MyBB