Prestashop:会话Cookie和登录 [英] Prestashop: Session cookies & login

查看:115
本文介绍了Prestashop:会话Cookie和登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望获得有关为Prestashop进行集中式登录(前台)的基本知识(一个单独的登录页面).

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

我有一个带有多个商店(多商店)的Prestashop安装.我已经尝试过Webservices API,但是找不到任何处理登录和会话cookie的方法.我该怎么做?

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?

例如: 在我的Prestashop中,我有3家商店,其中有3个不同的URL,例如:

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

当客户浏览到URL时,将显示mydomain.com(域顶部)登录页面.

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.

因此,从我的项目开始,我想知道如何通过Prestashop之外的页面登录用户.我可以从PS加载类并在外部使用它们吗?

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?

更新1: 我试图从mydomain.com/login/cookie.php中检索Cookie数据:

UPDATE 1: 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);
}

如果我在我的一家商店(mydomain.com/b)上登录,代码(mydomain.com/login/cookie.php)却说我没有登录.我在做什么错

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

更新2: 这有效,但仅适用于第一家商店.我无法从同一商店组中的其他商店收集数据.

UPDATE 2: This works but just for the first shop. I'm not able to collect data from the other shops in the same shop group.

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;   
}

推荐答案

在prestashop config.ini.php中密码已被破解,您可能具有不同的版本,这些版本对Cookie进行了不同的编码.

password is SALTED in prestashop config.ini.php and you might have different versions which code the cookie differently.

这篇关于Prestashop:会话Cookie和登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆