在另一个页面中获取magento会话变量 [英] Get magento session variable in another page
问题描述
我在magento模态页面的会话中设置了数组变量,并希望在另一个页面(如getuserdata.php)中进行检索,但不想在另一个页面中进行检索.我设置变量并进入一页然后完全检索.
I set array variable in session in magento modal page and want to retrieve in another page like getuserdata.php but not get in another page. I set variable and get in one page then in completely retrieve.
我的代码就像..
//首页代码.
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
$fldata = 'work for set data';
$session->setData("free_auth", $fldata);
//另一个页面代码.
session_start();
require_once ("../../app/Mage.php");
umask(0);
Mage::app('default');
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
$stl1 = $session->getData("free_auth");
任何人都可以帮助我解决这个问题.
Anyone can help me for that stuff problem..
推荐答案
如果我们在Magento中创建会话,则只能在magento/app文件夹中的Magento文件中使用该会话.如果要在您创建的外部文件中使用该会话,则必须首先在另一个Magento默认文件中获取该会话,然后调用jquery ajax函数并传递会话变量以将其获取到外部文件中.您还可以在不使用会话的情况下通过ajax传递变量.
If we create a session in Magento, then we can only use that session in Magento files like in the magento/app folder. If you want to use that session in external files create by you then you must first get the session in another Magento default file and then call a jquery ajax function and pass session variable through it to get it in an external file. You also pass the variable through ajax without the use of the session.
像这样设置会话数据.
$fldata = 'work for set data';
Mage::getSingleton('core/session')->setMyCustomData($fldata);
并获取这样的数据.
session_start();
$sessionfree = Mage::getSingleton('core/session', array('name' => 'frontend'));
$abcfree = $sessionfree->getMyCustomData();
这篇关于在另一个页面中获取magento会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!