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 !
I have tried using value variable type, session filtering and before it worked I cleared all cookies and it seems to work fine, see how to create your value in the first command string, maybe you chose the wrong array of values.
Programming training with picos school
Session variables are special variables that exist only while the user's session with your application is active. Session variables are specific to each visitor to your site. They are used to store user-specific information that needs to be accessed by multiple pages in a web application.
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
Thank you so much for this content.