Hi I have added the following code to the bottom of my index.php for a seperate store view in a subfolder of my magento installation.

$name = 'test'; $value = 'testval'; // set cookie Mage::getModel('core/cookie')->set($name, $value); //Show Cookie echo Mage::getModel('core/cookie')->get($name);

It isnt echoing anything and I have no cookie in chrome, does anyone know why this may be?



The set method in the cookie model uses the setcookie php function.
As you can see in the link, the cookie you set is available in the next request.

Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS arrays. Note, superglobals such as $_COOKIE became available in PHP 4.1.0. Cookie values also exist in $_REQUEST.

You are trying to get the cookie in the same request.

  • I see what you mean but even after clicking to a new page the cookie does not appear in my browsers settings and still does not echo. – KiwisTasteGood Apr 16 '15 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.