I am struggling with magento 2 session. I have created below controller file as a sample code.
<?php
namespace vendor_name\module_name\Controller\SetGetSession;
use Magento\Framework\App\Action\Action;
class SetGetSession extends Action
{
protected $customerSession;
public function _construct(
\Magento\Customer\Model\Session $customerSession
) {
$this->customerSession = $customerSession;
}
public function execute()
{
}
}
Can anyone please help me with how to assign data and retrieve it from session variable?
Thank you.