views:

118

answers:

2

Hi,

I have built a cakephp app that needs the user to login or register(for new users), when he tries to download the file. And I use to javascript to redirect users to login page, and once they login I want users directed back to the download page they were on.

I am using

$this->redirect($this->referer());

works fine in chrome and FF. In IE it does not work. It redirects user back to home page. document.referrer is blank.

I understand that in IE that document.referrer is populated only when user clicks on the link.

Is there a workaround or a hack to fix this(javascript or php). I appreciate any help.

Thanks.

+1  A: 

Referer is a completely optional HTTP header element. Many proxies and firewalls eliminate it. It is not recommended to build any logic on it. If you need to redirect to some previous page, you need to save that information explicitly for example as a session variable.

sibidiba
A: 

I don't know if this is applicable to you but most versions of IE also has a long-standing issue when using a confirm dialog. As sibidiba says, referer is unreliable - I'd pass the download page URL as a querystring param in your javascript redirect to login.

Nev Stokes