0

I created a custom success_handler for my login, and here I want to check if the referer was external or not. How do I best do this?

$ref = $request->headers->get('Referer'); 

What is the best way to check if the referer is a local url (meaning: from within the symfony project) or external ?

Thanks in advance.

Chi
  • 1,320
  • 1
  • 14
  • 48

1 Answers1

2

You can get a current domain

$this->getRequest()->getHost()

And then match it via regex see here: Regex to match simple domain

Community
  • 1
  • 1
Pawel
  • 1,672
  • 2
  • 18
  • 24
  • 1
    I understood that, he wanted to check if project is external (IMHO external means from other domain?). – Pawel Jan 20 '15 at 14:00
  • 1
    You could make the allowed hosts a parameter in parameters.yml and pass it along to the success_handler and check if $ref is in there – René Jan 20 '15 at 15:56