cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Magento 2 session data outside of Magento

Accessing Magento 2 session data outside of Magento

I have Magento 2 installed in a directory at mydomain.com/shop and I want to access the user's session data outside of that folder (specifically user id and isLoggedIn) so I can use it to log them into another app. I set my Magento cookie path to "/" but what code do I need to grab the session from domain.com/file.php?

4 REPLIES 4

Re: Accessing Magento 2 session data outside of Magento

Hi,

You should:

1. Set correct session_id($sid) the same like in magento.

2. Set correct session_save_path like in magento(disk,redis or something else)
3. Make session_start()

Session data will be available in $_SESSION.

 

Contact me in PM if you need more help.

 

Thanks.

Re: Accessing Magento 2 session data outside of Magento

I do not need to set the cookie/session data separately I just need to access the built in Magento session methods. 

Re: Accessing Magento 2 session data outside of Magento

Me too... Anyone have any idea?

I need something like if ($magentoSession->isLoggedIn() == TRUE) from outside of Magento. I set the cookie path to "/" but how do I access it the Magento way?

Re: Accessing Magento 2 session data outside of Magento

Is it secure to rely on the REST API like this to get the user ID and if they are logged in or not?

 

http://mysite.com/rest/V1/customers/me