[英]Cakephp 2.0 : Session is false with my custom helper
I am facing a problem regarding the Session. 我在本届会议上面临一个问题。 When I had my custom Helper in my controller, the debug($this->Session->read()) give me false
. 当我在控制器中有自定义的Helper时,debug($ this-> Session-> read())给我false
。 Custom Helper : 自定义助手:
<?php
App::uses('AppHelper', 'View/Helper');
class customFunctionsHelper extends AppHelper {
public function FormatAddress($address)
{
$addr = "";
if($address['street_name_1'] != "")
$addr .= $address['street_name_1']."<br />";
if($address['street_name_2'] != "")
$addr .= $address['street_name_2']."<br />";
if($address['street_name_3'] != "")
$addr .= $address['street_name_3']."<br />";
if($address['city'] != "")
$addr .= $address['city'].", ";
if($address['zipcode'] != "" && $address['state'] != "")
$addr .= $address['state']." ".$address['zipcode']."<br />";
else
$addr .= $address['zipcode']."<br />";
if($address['country'] != "")
$addr .= $address['country'];
if($addr != "")
return $addr;
else
return "<i>Not specified</i>";
}
public function EchoInfo($info)
{
if($info != "" && $info != 0)
return $info;
else
return "<i>Not specified</i>";
}
}
?>
In my controller, when I had CustomFonctions in the $helpers variable, I have this session problem : 在我的控制器中,当我在$ helpers变量中有CustomFonctions时,我遇到了以下会话问题:
class AgendaController extends AppController {
public $helpers = array('Html', 'Form','CustomFunctions');
......
Evaluating : 评估 :
debug($this->Session->read());
this give me : 这给我:
false
Therefore, the $this-Session-setFlash() doesn't work with my custom helper CustomFunctions. 因此,$ this-Session-setFlash()无法与我的自定义帮助程序CustomFunctions一起使用。 When I remove the custom helper, it works good... Does someone have an idea ? 当我删除自定义帮助程序时,它很好用...有人有主意吗?
You have to include SessionHelper
in AppHelper
or customFunctionsHelper
File. 您必须在AppHelper
或customFunctionsHelper
文件中包括SessionHelper
。 If you want to use it. 如果要使用它。
thanks :) 谢谢 :)
When I remove the CustomFunctions
helper in the $helpers
array. 当我删除$helpers
数组中的CustomFunctions
助手时。 It works and I can access to my custom functions. 它有效,我可以访问我的自定义功能。 It seems that it is not necessary to declare a custom helper in the $helpers
array... 似乎没有必要在$helpers
数组中声明自定义帮助器...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.