Questions
0 Answers
You can get session data in cache using obejct manager. So using following code you can get customer session data with cache enabled
namespace QaisarSatti\Module\Block;
class HelloWorld extends \Magento\Framework\View\Element\Template
{
protected $objectmanager;
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectmanager
) {
$this->objectmanager = $objectmanager;
}
public function getCustomerData()
{
$customerSession = $this->objectmanager->create('Magento\Customer\Model\SessionFactory')->create();
return $customerSession;
}
}
class HelloWorld extends \Magento\Framework\View\Element\Template
{
protected $objectmanager;
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectmanager
) {
$this->objectmanager = $objectmanager;
}
public function getCustomerData()
{
$customerSession = $this->objectmanager->create('Magento\Customer\Model\SessionFactory')->create();
return $customerSession;
}
}