PrestaCraft on Facebook

Please like our page on Facebook to get notifications about new tutorials :)


PrestaCraft

PrestaCraft on Facebook

Please like our page on Facebook to get notifications about new tutorials :)


PrestaCraft

Today I will show you how can you simple set and get your custom cookie variable.
It is useful when you want to keep locally on user’s PC some settings.

Setting cookie

$this->context->cookie->__set('your_cookie_name', 'your cookie value');
$this->context->cookie->write();

Getting cookie

$this->context->cookie->__get('your_cookie_name');

Check if cookie exists

$this->context->cookie->__isset('your_cookie_name');

Deleting cookie

$this->context->cookie->__unset('your_cookie_name');

Final words

Remember – if you don’t have access to $this->context, you can replace it with Context::getContext().

That’s all – as simple as that!

Leave a comment

Your email address will not be published.

1 comments

Leave a comment

Your email address will not be published.