我有以下代码:
function success()
{
if(!$this->referer(array('controller'=>'contact','action'=>'index')))
{
$this->redirect(array('controller'=>'contact','action'=>'index'));
}
}我正在尝试检查用户是否已经从索引操作访问了成功页面,如果没有,则将它们发送回索引方法,这样,如果他们以前没有提交一些关于索引操作的数据,他们就不能查看成功页面。
然而,它不起作用,因为用户仍然可以访问成功页面,即使他们没有首先访问索引页面...
有人能帮上忙吗?谢谢
发布于 2011-07-24 20:04:59
function success()
{
if($this->referer() != Router::url(array('controller'=>'contact','action'=>'index')))
{
$this->redirect(array('controller'=>'contact','action'=>'index'));
}
}发布于 2013-12-05 17:17:28
尝试在Router::url的末尾添加true,函数获取完整的url:
if($this->referer() != Router::url(array('controller'=>'contact','action'=>'index'),true))发布于 2011-07-24 19:07:43
我想那样是行不通的。现在,您只需使用该代码设置默认referer。尝试如下所示:
if($this->referer() != Router::url(array('controller'=>'contact','action'=>'index')))编辑:更正代码
https://stackoverflow.com/questions/6806101
复制相似问题