namespace Ravi\Learn\Helper;
use Magento\Framework\App\Helper\Context;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
/**
* @var \Magento\Customer\Model\Session
*/
protected $customerSession;
public function __construct(Context $context, $customerSession)
{
parent::__construct($context);
$this->customerSession = $customerSession;
}
public function getSess(){
return $this->customerSession->getId();
}
}
di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Ravi\Learn\Helper\Data">
<arguments>
<argument name="customerSession" xsi:type="object">Magento\Customer\Model\Session</argument>
</arguments>
</type>
</config>