开发者

get parameters from $_SERVER['HTTP_REFERER']

开发者 https://www.devze.com 2023-01-24 23:14 出处:网络
I want 开发者_Go百科to get a value from the http_referer in the same/similar way you\'d get it from a request:

I want 开发者_Go百科to get a value from the http_referer in the same/similar way you'd get it from a request:

$this->_getParam('order', 0);

I thought I'd try something like this:

$lastrequest = new Zend_Controller_Request_Http($_SERVER['HTTP_REFERER']);
$lastorder = $lastrequest->getParam('order', 0);

But that doesn't work. There are no parameters. getParams returns an empty string. What am I missing? Is there a better way to do this?

Thanks!


This is generally a bad idea.

On top of what Justin pointed out, it's easier to just pass those values on to the new page directly rather than trying to parse them from the referrer.


From the PHP docs for HTTP_REFERER:

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

So keep in mind this parameter may not even be set by the browser...

0

精彩评论

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