cancel
Showing results for 
Search instead for 
Did you mean: 

Handing Session Variables

SOLVED

Handing Session Variables

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Handing Session Variables

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

View solution in original post

5 REPLIES 5

Re: Handing Session Variables

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 !

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !

Re: Handing Session Variables

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

Re: Handing Session Variables

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. 

 

Mypascoconnect 

Re: Handing Session Variables

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

View solution in original post

Re: Handing Session Variables

Thank you so much for this content.

skylightpaycard