在另一个页面中获取 magento 会话变量

Get magento session variable in another page(在另一个页面中获取 magento 会话变量)
本文介绍了在另一个页面中获取 magento 会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 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 文件中使用该会话,例如在 magento/app 文件夹中.如果您想在您创建的外部文件中使用该会话,那么您必须首先在另一个 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 会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)