Reputation: 28803
I have the following code:
function success()
{
if(!$this->referer(array('controller'=>'contact','action'=>'index')))
{
$this->redirect(array('controller'=>'contact','action'=>'index'));
}
}
I'm trying to check if the user has accessed the success page from the index action and if not then send them back to the index method so they can't view the success page if they haven't previously submitted some data on the index action.
It doesn't work however as the user can still visit the success page even if they haven't visited the index page first...
Can anyone help? Thanks
Upvotes: 2
Views: 8517
Reputation: 31
try to add true on the end of Router::url, function to get full url:
if($this->referer() != Router::url(array('controller'=>'contact','action'=>'index'),true))
Upvotes: 3
Reputation: 740
I guess that won't work like that. You are now just setting default referer with that code. Try something like:
if($this->referer() != Router::url(array('controller'=>'contact','action'=>'index')))
Edit: corrected the code
Upvotes: 1
Reputation: 28803
function success()
{
if($this->referer() != Router::url(array('controller'=>'contact','action'=>'index')))
{
$this->redirect(array('controller'=>'contact','action'=>'index'));
}
}
Upvotes: 3