As I know there isn't a core/session
in Magento 2 [source], I've created a custom session using customer/session
as given below:
public function __construct(
\Magento\Customer\Model\Session $customerSession,
....
) {
$this->customerSession = $customerSession;
...
}
public function execute() {
$this->customerSession->setOtp(5); // To set session value
$this->customerSession->getOtp(); // To get session value
}
$this->customerSession->destroy();
will destroy whole customer session, which I do not want.
Is it possible to destroy this particular otp
session value automatically after 30 minutes?