简体   繁体   中英

I can't get customer session in my magento external site (same domain)

I'm developing a small application into magento folder, ie (magento/myApp).

I'd like to get the customer session in my magento/myApp folder once a customer have logged in from Magento site, I mean, get the session in my external folder.

I'm doing this:

Mage::getSingleton("core/session", array("name"=>"frontend"));
$session = Mage::getSingleton("customer/session", array("name"=>"frontend"));

if(!$session->isLoggedIn()){ 
 //Do something
}
else {
//Do something else
}

I've tried different ways to get customer session in my external site, and I couldn't.

My magento version is: 1.7.0.2. I've searched a lot in internet, and not found nothing yet. Just get customer session into my external site (same domain).

This is my System -> Configuration -> Web -> Session Validation Settings :

Use SID on Frontend: YES.

Take a look at How to access Magento customer's session from outside Magento?

Also you will need to include Mage.php

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM