开发者

Redirect is not working in IE

开发者 https://www.devze.com 2023-01-17 00:10 出处:网络
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 log开发者

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 log开发者_如何学Cin 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消