Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework: Get Referrer Page?

Tags:

Is there any way in Zend Framework to grab the url of the page the user visited last?

I don't really want to use $_SERVER['HTTP_REFERRER'].

like image 733
Sjwdavies Avatar asked May 24 '12 15:05

Sjwdavies


2 Answers

MWOP has put a good post here showing you how to get HTML headers (including referer).

http://zend-framework-community.634137.n4.nabble.com/Referer-td3007321.html

// In an action method of a controller
$request = $this->getRequest();
$request->getHeader('referer');
like image 66
Alan Lapington Avatar answered Jan 03 '23 16:01

Alan Lapington


From a controller method:

$this->getRequest()->getServer('HTTP_REFERER')

basically the same as using $_SERVER, but without causing problems in unit testing.

like image 45
Tim Fountain Avatar answered Jan 03 '23 16:01

Tim Fountain