Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sarathiscookie's avatar

How can we use HTTP_REFERER in laravel?

I tried $request->server('HTTP_REFERER'); in my app but getting result is null why? I am using laravel 5.2.

0 likes
3 replies
sarathiscookie's avatar
Level 2

When I var_dump($_SERVER). This list is not showing HTTP_REFERER. This is set by the user agent. Not all user agents will set this. I think this is the reason.

bashy's avatar

There's no reason that shouldn't work (if a referrer is actually present). How are you testing it?

ccolorado's avatar

I have the same issue between two laravel sites. I can't get the referer using the Request::server and also the $_SERVER array is missing this value.

On the Chrome's developer tools I do see the header being send in the ajax request to the serving site

Please or to participate in this conversation.