Welcome Guest, Not a member yet? Register   Sign In
set_cookie not setting cookie
#21

[eluser]Unknown[/eluser]
Solution: You have to specify the expire number of seconds...

Expire by default is $expire = ''

Hence it hits ! is_numeric($expire) as TRUE

and sets $expire to time() - 86500 (Yesterday)

So your cookie expires immediately if you do not specify when you want it to expire
#22

[eluser]ray023[/eluser]
My issue was the cookie_domain configuration setting in config.php. I had it set to localhost, but that was not working.

When I cleared out the value for that cookie setting, it worked.

If this is not the solution for you, then you can probably determine the problem by manipulating the variables in the set_cookie call of the cookie_helper to determine the issue.

Also, I found the Firebug extension Firecoookie to be extremely useful in determining if the cookie was actually set. It worked better than seeing if the php command setcookie returned true.
#23

[eluser]WanWizard[/eluser]
It is very important to set cookie_domain and cookie_path to the correct values. Browsers are implementing more and more security these days, invalid cookies will be rejected.

The RFC states that a cookie domain should contain at least one dot, and for some situations even two. Therefore 'localhost' is an invalid cookie domain.
#24

[eluser]InsiteFX[/eluser]
Also as WanWizard said above, If you are using IE you need to
remove the _ (underscore character)

from:
$config['sess_cookie_name'] = 'ci_session';
to:
$config['sess_cookie_name'] = 'cisession';

IE doe's not like the underscore character!

InsiteFX
#25

[eluser]Unknown[/eluser]
The issue is that the expire parameter is passed as a string, not numeric.

Incorrect:

Code:
set_cookie(array('name'=>'cookie_name','value'=>'1','expire'=>'60*60*24*365'));
(notice the quotes)

Correct:

Code:
set_cookie(array('name'=>'cookie_name','value'=>'1','expire'=>60*60*24*365));

This solution worked for me, let me know if this fixes your problem.
#26

[eluser]Fabdrol[/eluser]
[quote author="levani" date="1318250997"]My problem was caused by the 'secure' parameter set to TRUE. When I set it to FALSE it worked.[/quote]

I got the same issue. Seems it's a CI bug. Lot's of bugs lately btw. I'm a long-time CI user and I've never encountered as many bugs with the current version as with any version before..
#27

[eluser]CroNiX[/eluser]
You mean you have SSL enabled and working properly on your server, and when Secure is set to TRUE it doesn't work? That would be a bug assuming everything else is set properly. If you don't have SSL enabled and trying to use secure=TRUE, you can't as secure cookie requires SSL to be enabled as that's what it's using to set the "secure" cookie, just like a regular PHP secure cookie.

http://php.net/manual/en/function.setcookie.php
#28

[eluser]Fabdrol[/eluser]
[quote author="CroNiX" date="1340902866"]You mean you have SSL enabled and working properly on your server, and when Secure is set to TRUE it doesn't work? That would be a bug assuming everything else is set properly. If you don't have SSL enabled and trying to use secure=TRUE, you can't as secure cookie requires SSL to be enabled as that's what it's using to set the "secure" cookie, just like a regular PHP secure cookie.

http://php.net/manual/en/function.setcookie.php[/quote]

Ah, that's it then. I assumed it would encrypt the cookie, like the encrypt sess cookie setting.





Theme © iAndrew 2016 - Forum software by © MyBB