如何在Magento的子商店中访问会话或cookie变量

I am trying to access my session or cookie variables on sub stores but didn't get any values there.I am trying like this :

 Mage::getModel('core/cookie')->set("foo","magento");
          $_COOKIE['foo'] = "magento";
          Mage::getSingleton('core/session')->setData("foo","magento");

When i try to access these variable on sub stores it returns empty result.I have created sub stores with multisite like http://example.com/ and http://example.com/secrondstore I have created addson domain that link second store like this http://secondstore.com/.May be different stores with addon have effect on this

Possible duplicate of : PHP – setcookie() not working

You will need to use PHP's built in method to set cookies: setcookie, then use $_COOKIE[]=''

setcookie('foo', 'magento',time()+3600*24);
$_COOKIE['cookie'] = 'magento';