Reputation: 123
Hi I have set a cookie in Magento as:
$cookie_value = $_GET["utm_source"];
$cookie = Mage::getSingleton('core/cookie');
$name = "Pixel_Track";
$url = "stage.test.com";
$expiry = time() + 86400 * 365 * 1;
$cookie->set($name, $cookie_value ,$url,$expiry);
Now I want to get on another page and I am using:
$cookie = Mage::getSingleton('core/cookie')->get($name);
Where I am doing wrong? Because print_r
is not giving the cookie name.
Upvotes: 0
Views: 2777
Reputation: 1
Try this:
echo $cookie = Mage::getModel('core/cookie')->get("Pixel_Track");
//your can't get your variables in another page, so please type cookie name.
Upvotes: 0
Reputation: 123
I just got the solution by defining the path
attribute of cookie.
$cookie->set($name, $cookie_value ,time()+86400,'/');
Upvotes: 0
Reputation: 100175
Mage_Core_Model_Cookie
class contains functions to set, get and delete cookie. so try:
$cookie_value = $_GET["utm_source"];
$cookie = Mage::getModel('core/cookie');
...
$cookie->set($name, $cookie_value, $period ,$url,$expiry);
and
$cookie = Mage::getModel('core/cookie')->get($name);
Upvotes: 1