在Magento中创建自己的会话

时间:2013-05-31 02:52:33

标签: php magento magento-1.7


我想在magento上创建自己的会话,所以这是我的代码:

require 'app/Mage.php';

$value = "Hello World";
Mage::getSingleton('core/session')->setMyOwnSess($value);

但我有一个错误说:

 Fatal error: Call to a member function getModelInstance() on a non-object in C:\wamp\www\magento\app\Mage.php on line 462

其他: 我正在尝试在位于config.php

includes/config.php上创建会话

任何人都可以帮助我......提前感谢!

2 个答案:

答案 0 :(得分:2)

你需要初始化magento。初始化它的最安全的方法是在实际调用模型之前使用初始化程序

Mage::init();

或者这也应该解决你的问题

Mage::app('default');

答案 1 :(得分:1)

让不同领域的会议发挥作用的关键是行

$core_session = Mage::getSingleton ( 'core/session', array ('name' => 'frontend' ) 

在使用其他之前。

所以你应该尝试下面的

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

$url = Mage::getUrl ( '*/*/*', array ('_current' => true ) );

Mage::getSingleton ( 'core/session' )->setLastUrl ( $url );

上面只是骨架代码。你可以根据需要改变它。