Page 1 of 1

can't read cookie from udt

Posted: Tue Aug 05, 2014 11:35 pm
by GarretDekker
Hi,
Not sure if I'm posting this in the right place but maybe a moderator can move it if not.
I'm having a problem with reading a cookie from an udt. It's a cookie I set for a captcha check. I can see the cookie if I check it with Firefox but CMSMS doesn't see it. Not with $_COOKIE or print_r($_COOKIE).
Anybody got an idea what I'm doing wrong?
thanks,
Garret

Re: can't read cookie from udt

Posted: Wed Aug 06, 2014 5:41 am
by Rolf
Probably the way the cookie is set is wrong. check the code I used in my cookie consent tag how I set it up there. might help...
http://viewsvn.cmsmadesimple.org/filede ... onsent.php

Re: can't read cookie from udt

Posted: Wed Aug 06, 2014 6:09 am
by GarretDekker
Thanks Rolf, I see you're using javascript to set the cookie. I would like to use php and am using setcookie("cookiename",$cookievalue) and trying to read it in the udt with $_COOKIE["cookiename"].
Is that not possible?

Re: can't read cookie from udt

Posted: Wed Aug 06, 2014 9:52 pm
by velden
Read http://php.net/manual/en/function.setcookie.php and have look at 'path' parameter.

Re: can't read cookie from udt

Posted: Wed Aug 06, 2014 10:17 pm
by GarretDekker
Thanks velden, that was it. Should have read the documentation better. Set path to '\' and cookie could be read in udt.

Re: can't read cookie from udt

Posted: Thu Aug 07, 2014 2:20 am
by calguy1000
See the cms_cookies class here: http://apidoc.cmsmadesimple.org/
it takes care of those issues for you.

cms_cookies::set('foo','bar');

$foo = cms_cookies::get('foo');
die($foo); // outputs 'bar'