I am getting Sessions cleared in my app and this makes the values lost. I am using the Session variables to avoid calling duplicate functions in different API's. The Session variable works perfectly but only problem it gets cleared regularly and the values gets lost. How to solve this. My code for handling Session keys are below
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $objectManager->get('Magento\Customer\Model\Session'); $customerSession->setMyValue('0'); if ($customerSession->getMyValue() == '0') //Process my function
The $customerSession->getMyValue() works in multiple files, but fails after session expires. Anyway to fix this?
Regards
Ansif
Solved! Go to Solution.
Sorry for the late reply. I was using an external API library to send and receive functions and this causes the Session and Cookie variables getting cleared. Anyway I have solved it using an Order variable which in my case works perfectly.
Thanks for your support
Hello @ansif_ibrahimkutty ,
Do you want to increase the session time ? you can do as per this guide :
https://docs.magento.com/user-guide/customers/customer-online-options.html
if you don't want to increase how you will get session ? the other way is to use cookie management.
hope it helps !
Sorry for the late reply. I was using an external API library to send and receive functions and this causes the Session and Cookie variables getting cleared. Anyway I have solved it using an Order variable which in my case works perfectly.
Thanks for your support