Connecting PHP web app to cs-cart sessions

Hi, I’m porting my php web application to connect to cs-cart instead of my old shopping cart.



The web app needs to be able to determine the user from the session/cookie data and then look up the cs-cart database to get a list of orders for that user.



I’m having trouble figuring out what session variables/cookies cs-cart sets and how to access them from a php page.



Any ideas?

Can you elaborate? The things you are asking for are going to be private to the user’s session environment. A “web app” is normally an independent entity tht connects to the cart and then performs actions based on requests.



A user’s user id is kept in the $_SESSION[‘auth’][‘user_id’] variable and the groups they belong to is an array of $_SESSION[‘auth’][‘usrgroups’]. There are a few others, but this is primarily what’s stored in the SESSION for a logged in user.



For anonymous users, their session info is kept around for a couple of weeks in the cscart_sessions table which is keyed by a cookie value. They have no user_id because they are not logged in.

Hi, thanks for that information. To answer your question:



After a user logs in to cs-cart they will click a link to use my web app. They get different access to the web app depending on what product they purchased through cs-cart.



So my plan is to connect to their cs-cart session so that I can determine what products they have bought and hence provide the allowed access.



I’m new to cs-cart, so feel free to suggest the “obvious solution” if I’m missing it :slight_smile:



Cheers.

It’s stored in their session then. But if you invoke a new domain, the data from the cart sessiion will not be available to you.



Look at the $_SESSION[‘auth’] array for what’s available to you.

I’m having trouble figuring out how to find the cs-cart session.



The usual session_start() doesn’t connect to it :frowning:



Am I missing something obvious?

Grepping the cart files for init_user_session_data and fn_get_session_data should help a little with what you are trying to do

Hi,



I am working on the same kinda situation and I want to access the session data for the web app that is to be connected to my cs cart app.



I see that the sessions data can be accessed in the “cscart_sessions” table. In my localhost, I can get the session data from the sessions table. But when I try to do the same in my server, I couldn't since the session data seems to be encrypted.



I m not sure how do I decrypt the sessions data from “cscart_sessions” table. I m also not sure if that's the case. !



Instead I was trying to solve the issue by saving the logged in user id to cookies and even it doesn't seem to work fine in various situations.



Is there any other way to get the logged in user session to make use of it in my web app. ?



I tried calling $_SESSION['auth']['user_id'] outside the cs cart app and its not working. The web app is placed inside the cs-cart app folder listing like “cscart/feed” (feed is the web app folder name).



Any idea on how to do that?