0

I was working with symfony 2.0.12 but I have this problem: the page is not updated, always returns null.

public function cambiarlocaleAction($idioma)
{
    $this->get('session')->setLocale($idioma);
    $request = $this->get('request');
    return new Response ($request->headers->get('referer'));
    return $this->redirect($request->headers->get('referer'));
}

$request->headers->get('referer') always null why? in symfony 2.0.14 work.

3
  • 1
    Why do you return twice ? Commented Mar 1, 2013 at 16:21
  • use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\HeaderBag; working correctly thanks. Commented Mar 1, 2013 at 16:26
  • 4
    If you find the answer, post it and accept it Commented Mar 1, 2013 at 16:28

1 Answer 1

1

There is no guarantee the header referer is sent with the request. Typically if the user enters the URL directly, it's not present (and therefore if you try to retrieve it, the result is null). Even when user is following a link the browser is not obligated to send that header.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.