lucabek Posted August 7, 2017 Share Posted August 7, 2017 Hi, i would like to access the logged user data from a simple php page, hosted in the same server of shop, the page is pure php, no framework, how can i do? thanks! Link to comment Share on other sites More sharing options...
Scully Posted August 7, 2017 Share Posted August 7, 2017 Include init.php is not required at all. Link to comment Share on other sites More sharing options...
lucabek Posted August 8, 2017 Author Share Posted August 8, 2017 it works, if i include an iframe in domain B, same host, i see the user data, but i i use curl, of file_get_contents the user is not logged, it lost session id, any ideas? Link to comment Share on other sites More sharing options...
Scully Posted August 8, 2017 Share Posted August 8, 2017 file_get_contents is not able to handle cookies. curl is. Therefore, you won't be able to solve this with file_get_contents. But anyway - why use curl? You could call any function / controller within your script without the need of using this external tools. Link to comment Share on other sites More sharing options...
lucabek Posted August 9, 2017 Author Share Posted August 9, 2017 I have a page php in server B and prestashop is in server A, I want to compile a form from php page in server B with the user details logged in server A, what do you suggest!? Link to comment Share on other sites More sharing options...
Scully Posted August 9, 2017 Share Posted August 9, 2017 if you are working cross server, you'll need something like curl. quicker and eventually more reliable would be to process data on the prestashop server. Link to comment Share on other sites More sharing options...
lucabek Posted August 9, 2017 Author Share Posted August 9, 2017 I have made an API on the server prestashop that return the current logged user as xml, if I call it by URL, it works fine, if in server B I include I frame with src of API I see user data, but with curl or Ajax getjson I see no logged user, this is the problem! Do you have idea how to pass a cookie or session to curl!??? Link to comment Share on other sites More sharing options...
Scully Posted August 9, 2017 Share Posted August 9, 2017 Probably easier to get to a solution if you describe what your goal exactely is? And - what is logged in user. An admin or a customer? If latter is the case. There are tables like ps_guest and ps_connections. There you find all data from stored connections with customer id. Link to comment Share on other sites More sharing options...
lucabek Posted August 9, 2017 Author Share Posted August 9, 2017 The user is customer, the problem is that if I call a script form B server de logged user is null, it seems curl not use my session! Link to comment Share on other sites More sharing options...
Scully Posted August 9, 2017 Share Posted August 9, 2017 Curl needs to know the session id. If you don't pass it, you don't get a result. Why not allow the remote server to access the prestashop database? All information is available there. And you didn't explain what your real goal would be. Link to comment Share on other sites More sharing options...
lucabek Posted August 9, 2017 Author Share Posted August 9, 2017 User make a login in prestashop then go to other domain and register to a service using a form, I want to compile the form with initial data of the logged user! This is the goal Link to comment Share on other sites More sharing options...
Scully Posted August 9, 2017 Share Posted August 9, 2017 (edited) Access you prestashop datatbase. Everything else with file_get_contencts, curl or iframes gets difficult or is impossible at all. file_get_contents is no way at all and with curl you needed the session id. which we don't know as per my know how. Edited August 9, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
lucabek Posted August 9, 2017 Author Share Posted August 9, 2017 But to query the database I need to know customer id Link to comment Share on other sites More sharing options...
Scully Posted August 9, 2017 Share Posted August 9, 2017 (edited) Mail address would be convenient as well - and the user might know his address. Once he enters it, you fill up the rest. Or your could pass the customer_id as parameter with the link to the external site. So the remote server would know what to look up. Edited August 9, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now