如何从Magento外部访问Magento用户会话? [英] How to access Magento user's session from outside Magento?

查看:62
本文介绍了如何从Magento外部访问Magento用户会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问网站另一部分中的Magento客户会话.

Im trying to access the Magento customer session in another part of my website.

domain.com/shop/ <- Magento
domain.com/test.php

这家商店本身就像一个魅力,但是我试图在test.php中确定是否有客户登录,所以我可以显示他的名字以及到他的购物车的链接.

The shop itself works like a charm, however im trying to determine within test.php if a customer is logged in, so I can display his name with a link to his cart.

到目前为止 test.php 的内容:

<?php
require_once dirname(__FILE__).'/shop/app/Mage.php';
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
var_dump(Mage::getSingleton('customer/session')->isLoggedIn());
?>

我一直收到 bool(false)返回.我在domain.com/shop/上登录了Magento,因此应该为"true".

I keep getting bool(false) returned. I'm logged into Magento at domain.com/shop/ so ‘true’ is expected.

我忘记了什么吗?

推荐答案

我建议检查Magento设置的cookie的路径.很有可能它被设置为/shop,因此您上面的文件将无法访问该cookie.

I would recommend checking the path of the cookie that Magento sets. Most likely, it is set to /shop, so the cookie will not be accessible to your file above it.

您可以在控制台中的System -> Configuration -> Web (under the General heading) -> Session cookie management

这篇关于如何从Magento外部访问Magento用户会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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