CodeIgniter Forums
cookies not found in codeignitor - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: cookies not found in codeignitor (/thread-62458.html)



cookies not found in codeignitor - cupboy - 07-16-2015

I set a cookie with javascript and read it back on the next line, and then it's gone. Is codeignitor messing with cookies somehow? I have tried using the cookie helper and also reading the cookies the old fashioned PHP way, but the cookie cannot be found. Are there any settings I should check other than those I have listed? Also, checking the log I see this: Global POST, GET and COOKIE data sanitized ... what does that mean?
Code:
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;



RE: cookies not found in codeignitor - InsiteFX - 07-16-2015

Cookies will not show up until the next page refresh!


RE: cookies not found in codeignitor - Blair2004 - 07-17-2015

that's the matter with cookie..
just check in your code if any output is not send before creating cookie... just as session_start()...


RE: cookies not found in codeignitor - cupboy - 07-18-2015

The problem isn't that the cookie isn't being created, it is since I read it immediately after creating it, just that it's gone after that. Why would it be deleted? It has an expiration of 1 day on it. Coding the same thing outside of codeignitor works fine.


RE: cookies not found in codeignitor - cupboy - 08-30-2015

6 weeks later and I still haven't figured this problem out.  Does nobody but me use Javascript or jQuery in Codeignitor? I can't set a cookie and then read it later? Where does the cookie go? Does codeignitor somehow delete cookies? The cookie is being set with Javascript and read by Javascript. Seems there should be no codeignitor intervention there. Is there a tool I can use that monitors cookies?


RE: cookies not found in codeignitor - PaulD - 08-31-2015

I am no expert by a long way, but I have had no problems with storing data in a cookie whatsoever. Can you post the code that is actually writing and then reading the cookie data and I will have a look to see if I can help, although can't promise I will be able to see anything.

If you are using jquery to read the cookie it is probably an issue with your jquery, not CI. Jquery often sets cookies that are only available in the scope of the original js, and are quite temporary and short lived, which is what it sounds like is happening to your cookie data.

http://stackoverflow.com/questions/95213/can-jquery-read-write-cookies-to-a-browser

Best wishes,

Paul.


RE: cookies not found in codeignitor - mwhitney - 08-31-2015

What is the code you are using to write the cookie? What is the code you are using to try to read the cookie? Did you try setting the cookie_domain to '.your-domain.com'? Are you using the same time reference on your server and client?

The message 'Global POST, GET and COOKIE data sanitized' is a debug log message from the _sanitize_globals() method in CI's Input class. If your cookie's name or data uses certain characters, it may become unavailable to CI, but it shouldn't change its accessibility via JavaScript.