Monday, August 29, 2011

CakePHP Auth redirection not classed as referrer

When a user tries to access a protected action they are automatically
taken to the login form which then sets the previous page in a session
called Auth.Redirect and on successful login sends the user back to
that session value.

However if I put a check to see the referrer it will NOT show the
previous URL!

This causes a problem in my app as I do a check in the code to see if
a user has come direct to the login page (typed it in the address bar)
or has come from another page within the app.

e.g.

$referer = env('HTTP_REFERER');

if(empty($referer)
{
'user has typed the url manually or clicked a link from an
external website';
}

The issue is that when a user is taken to the login form by the auth
component it will leave the referer empty! But this is wrong as the
referer WAS the last page!

a) is this a bug in CakePHP? Why isn't it being classed as a refer?

b) how do I get around this?

Cheers

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: