Jump to content

Alternative login page & session cookies


Phillys93

Recommended Posts

I would like some help with the fundamentals for making a centralized logon (front office) for Prestashop - a separate logon page.

I have a Prestashop installation with multiple shops (multistore). I have tried the Webservices API but doesn't find any way to handle logins and session cookies. How do I do this?

 

For example: 

In my Prestashop I've got three shops with three different URLs, such as:

A => mydomain.com/a

B => mydomain.com/b

C => mydomain.com/c

 

When a customer browses to the URL, mydomain.com (top of domain) a logon page will appear.

 

The user logs in and gets redirected to the shop where he/she is registered.

 

So to get started with my project I would like know how to login a user through a page outside Prestashop. Can I load classes from PS and use them externally?

Edited by Phillys93 (see edit history)
Link to comment
Share on other sites

I tried to retrive cookie data from mydomain.com/login/cookie.php:

include_once('../config/config.inc.php');
include_once('../config/settings.inc.php');
include_once('../classes/Cookie.php');
$cookie = new Cookie('ps'); // Use "psAdmin" to read an employee's cookie

if(!$cookie->isLogged()){
  echo ("Please login");
  exit;
}
else{
  echo ("Logged in as: ".$cookie->customer_lastname." ".$cookie->customer_firstname);
}

Eventough I was logged in at one of my shops (mydomain.com/b) the code (mydomain.com/login/cookie.php) says I'm not logged in. What am I doing wrong?

Link to comment
Share on other sites

Anyone?

 

I got this to work for the first (default shop) but I'm not able to collect data from the other shops:

include_once('../config/config.inc.php');
include_once('../config/settings.inc.php');
include_once('../classes/Cookie.php');
$lastname=Context::getContext()->customer->lastname;


if(!Context::getContext()->customer->isLogged()){
echo "Please login";
exit;
}
else{
echo "Logged in as".$lastname;
exit; 
}
Edited by Phillys93 (see edit history)
Link to comment
Share on other sites

  • 3 years later...

im having a problem with multistore and i think it is cookies / sessions... so MainShop.com/shop is where PS is installed. MainShop.com/shop/ShopA , works perfectly. However cant add to cart and cant log in, when i direct ShopA.com to MainShop.com/shop/ShopA ?? Can anyone help, im losing a lot of clients over this not working!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...