Welcome Guest, Not a member yet? Register   Sign In
cookies not found in codeignitor
#1

(This post was last modified: 07-16-2015, 01:29 PM by cupboy.)

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;
Reply
#2

Cookies will not show up until the next page refresh!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 07-17-2015, 10:03 AM by Blair2004.)

that's the matter with cookie..
just check in your code if any output is not send before creating cookie... just as session_start()...
NexoPOS 2.6.2 available on CodeCanyon.
Reply
#4

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.
Reply
#5

(This post was last modified: 08-30-2015, 07:24 PM by cupboy.)

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?
Reply
#6

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...-a-browser

Best wishes,

Paul.
Reply
#7

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB