【问题标题】:PHP session echo 0PHP 会话回显 0
【发布时间】:2014-10-21 11:54:55
【问题描述】:

我尝试在打开购物车成功页面中设置像素,我有这个代码:

$order_id=(int)$this->session->data['order_id'];
$total_price=$this->cart->getTotal();

$output= "<img src=\"http://track.lead-r.ru/?method=reportAction&transaction_id=". $order_id . "&advertiser_id=2158&offer=2158VxTkF:". $total_price ."\" alt=\"\" style=\"width: 0; height: 0; position:absolute;\" />";

返回

<img src="http://track.lead-r.ru/?method=reportAction&transaction_id=0&advertiser_id=2158&offer=2158VxTkF:0" alt="" style="width: 0; height: 0; position:absolute;" /><div id="footer">

如果我设置

$order_id=123;
$total_price=123;

一切正常

<img src="http://track.lead-r.ru/?method=reportAction&transaction_id=123&advertiser_id=2158&offer=2158VxTkF:123" alt="" style="width: 0; height: 0; position:absolute;" /><div id="footer">

看看这个http://rghost.ru/57715199

【问题讨论】:

  • $this-&gt;session-&gt;data['order_id']; 不强制转换为 int 的值是多少?
  • 我试试 echo $order_id $total_price ?> 这也可以。然后他们“$order_id=(int)$this->session->data['order_id'];”和“$total_price=$this->cart->getTotal();” .我可以在页面上看到他们,但在查看源代码时为空
    .
  • 等我创建截图
  • 我和 eddard 的回答一样怀疑;你确定你已经在那个页面上开始了会话吗?
  • 想知道为什么在连接值时要转换为 (int)

标签: php session opencart


【解决方案1】:

我以前从未使用过 opencart,但我使用过 codeigniter,它看起来很相似,会话返回 0 的原因是因为会话实际上返回 false,并且因为您将其转换为 int,所以它显示 0。如果是可能然后检查您在哪里设置了会话数据。

【讨论】:

    猜你喜欢
    • 2011-06-21
    • 1970-01-01
    • 2013-07-22
    • 1970-01-01
    • 1970-01-01
    • 2011-12-23
    • 2011-06-02
    • 1970-01-01
    相关资源
    最近更新 更多