Jump to content

Right way to manage cookies


Promokit

Recommended Posts

Hi, guys.

I'm trying to set cookie correctly with javascript to be able to get it from Context::getContext()→cookies variable.

I have tried external jQuery solution as well as built-in library /js/jquery/plugins/jquery.cooki-plugin.js

Cookies always set correctly and available in browser's console and through $_COOKIE variable in php as well. But as you should know, that is not a Prestashop way to get cookies directly, and I have to use context. Unfortunately, my cookie is not available through context.

So the question is: How to set cookie to make it available in context?

Thanks in advance for suggestions!

Link to comment
Share on other sites

Hey Marek

So if I understood, if you create custom cookie in JavaScript you can not call it in PHP with

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

as it needs to be created with Context class ?

 

Could you then use Ajax to create cookie in JavaScript but that Ajax call would create cookie with Context in PHP ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...