問題描述
我在 magento 模態(tài)頁面的會話中設(shè)置了數(shù)組變量,想在另一個頁面(如 getuserdata.php)中檢索但不進入另一個頁面.我設(shè)置變量并進入一頁然后完全檢索.
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 中創(chuàng)建會話,那么我們只能在 Magento 文件中使用該會話,例如在 magento/app 文件夾中.如果您想在您創(chuàng)建的外部文件中使用該會話,那么您必須首先在另一個 Magento 默認文件中獲取該會話,然后調(diào)用 jquery ajax 函數(shù)并通過它傳遞會話變量以將其獲取到外部文件中.您還可以在不使用會話的情況下通過 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.
像這樣設(shè)置會話數(shù)據(jù).
$fldata = 'work for set data';
Mage::getSingleton('core/session')->setMyCustomData($fldata);
并像這樣獲取數(shù)據(jù).
session_start();
$sessionfree = Mage::getSingleton('core/session', array('name' => 'frontend'));
$abcfree = $sessionfree->getMyCustomData();
這篇關(guān)于在另一個頁面中獲取 magento 會話變量的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!