Magento: Save country in cookie
Followings are the code of save country in cookie in Magento:-
if($_GET['variablename']==true){ $storeId = $currentstore; $store_url =Mage::getModel('core/store')->load($storeId)->getUrl(); $cookie = Mage::getModel('core/cookie'); $period = time()+86400; $cookie->set('country', $storeId,$period, '/'); //header("Location:".$store_url); //exit; Mage::app()->getResponse()->setRedirect($store_url); } if(isset($_COOKIE['country'])){ $storeId = $_COOKIE['country']; $magento_store_id = Mage::app()->getStore()->getStoreId(); $redirect_to = Mage::getModel('core/store')->load($storeId)->getUrl(); if($storeId != $magento_store_id) { echo "<script type='text/javascript'>window.location.href='".$redirect_to."';</script>"; } }