How to grab and check cookies

Permalink 2 users found helpful
Does anyone know if there is a helper object of some sort for dealing with cookies in 5.7.

View Replies: View Best Answer
MrKDilkington replied on at Permalink Best Answer Reply
Hi wcldev,

I would look at this.

I was told by a core team member "generally, you shouldn't be using them for anything other than session". I think you can still use them to read cookies, just not for setting them.

$ch = Core::make('cookie');
// get cookie
$get_cookie = $ch->get('age');
// has cookie
$has_cookie = $ch->has('age');
wcldev replied on at Permalink Reply
Thank you for your message, I found it really useful. I didn't know there was an API reference so thanks for that tip. I was only needing to read a cookie set by a jQuery function. I used to do Concrete5 but I sadly drifted to WordPress because of the big code change and lack of documentation, thought I'd let it brew for a while but it seems very nice now and its potential is immense. I have now decided to come back as WordPress is proving difficult for a client to use and accomplish advanced designs. Thank you for your quick response.
SnefIT replied on at Permalink Reply
Yes, that's how I did it. Works fine.....

I have one strange problem with it though. I have an application that sends an ajax form, and in that action a cookie is set. On my laptop it works fine, on the hostingserver is doesn't work.

When I use the plain setcookie() it just works fine. So I could use that one, but that will not be accepted in a addon (but C5 itself uses setcookie more than once!).

Still puzzling along.....