会话变量在magento之外


Session Variable outside magento

我必须在magento之外的文件中读取$_SESSION['name'],或者更好的是在/magento/文件夹中。我尝试了任何解决方案,但没有得到好的结果。

示例

Mage::getSingleton('core/session')->setUName($_SESSION['username']);

在外部文件中使用此代码:

require_once("../app/Mage.php");
umask(0);
Mage::app();
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
Mage::init();
$_SESSION['username'] = Mage::getSingleton('core/session')->getUName();

结果???变量为空。。。。

我迷上了马根托。。。。我需要这个变量!!!!

如果有人能帮我,我会说谢谢。

快速解决方案:

Mage::getSingleton('core/session', array('name' => 'frontend'))->getUName();

说明:

会话在此开始:Mage_Core _Model_Session_Abstract_Varien::start()

当默认的magento试图启动会话时,它会使用param:$sessionName='frontend'运行。当您运行Mage::getSingleton('core/session')时,您可以实例化不带任何参数的会话。而且你没有完成必要的训练。因此,因为您需要再添加一个会话名称为的参数