Cookie only readable with PHP once logged in wordpress

This is a weird one. I’m creating a cookie with jquery cookie. Once the cookie is set, the page reloads and I’m able to read it using PHP’s $_COOKIE

That works fine on my DEV environment on wpengine.

Read More

Once I copy the whole thing to my live environment (still on wpengine)
the javascript cookie is set correctly, i can ouput the value in the console, however, the php is unable to read the cookie correctly.
EXCEPT
if I log to wordpress.

Is there any logical sense to this? Why does it work on my DEV and not on my live ? The cookie works only once i’m logged in wordpress.

using JS:

$.cookie('province', provinceCode,  { expires: 30, path: '/' });  

Reading it in PHP:

$provinceCode = $_COOKIE['province'];

Like i said, it works on different environments. It even works on the LIVE one but only when i am connected to the wordpress Admin. I have NO IDEA what to do…

Related posts