Magento: How to get visitor's cookies or sessi

2019-09-11 17:27发布

I want to log the recently viewed product for every visitor on the site. And for that the best way I believe is to log it via their cookie/session ID. How can I get the Session ID/Cookies of a visitor who is not logged in.

Thanks,

2条回答
一夜七次
2楼-- · 2019-09-11 17:48

To get Cookies

Mage::app()->getRequest()->getCookie();

To get Session Id

$session = Mage::getSingleton('customer/session', array('name' => 'frontend'));
echo $session->getId();
echo $session->getCustomerId();

FYI : There is a default magento functionality available for the recently viewed products

Please check the below url

Magento: Show Visitor's Recently Viewed Product

查看更多
闹够了就滚
3楼-- · 2019-09-11 17:56

you can get the visitor id by session

$vistitorId = Mage::getModel('core/session')->getVisitorId();
查看更多
登录 后发表回答