can't read cookie from udt

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
GarretDekker
New Member
New Member
Posts: 7
Joined: Thu Apr 17, 2014 3:18 am

can't read cookie from udt

Post 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
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: can't read cookie from udt

Post 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
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
GarretDekker
New Member
New Member
Posts: 7
Joined: Thu Apr 17, 2014 3:18 am

Re: can't read cookie from udt

Post 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?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: can't read cookie from udt

Post by velden »

Read http://php.net/manual/en/function.setcookie.php and have look at 'path' parameter.
GarretDekker
New Member
New Member
Posts: 7
Joined: Thu Apr 17, 2014 3:18 am

Re: can't read cookie from udt

Post by GarretDekker »

Thanks velden, that was it. Should have read the documentation better. Set path to '\' and cookie could be read in udt.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: can't read cookie from udt

Post 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'
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “The Lounge”