title: Symfony - How to redirect the user to last page visited after login?
body: <p>How to redirect the user to last page visited after login in Symfony with fosuserbundle?</p>
  
  <p>In my controller, I check first if user is logged in. Then if he isn't, I redirect him to the login page. Here is the short code I used at the beginning of my controller.</p>
  
  <pre><code>$autenthicated = $this-&gt;checkAuth();
  if($autenthicated==true){
    return $this-&gt;render('MainBundle:Default:home.html.twig');
  }else{
    return $this-&gt;redirect($this-&gt;generateUrl('login_connect'));
  }
  </code></pre>
  
  <p>The problem is that after the user has logged in, he is redirected to the main page instead the last page visited.</p>
  
  <p>How should I redirect him to my custom login page? apparently this is not working:</p>
  
  <pre><code>return $this-&gt;redirect($this-&gt;generateUrl('login_connect'));
  </code></pre>