Q:

Symfony2: login from each page

I have a Symfony2 Web application which requires user login to perform such useful operations.  In Symfony, you can put a link to the login page and then the security handled by the framework do the rest.  You have to define the route for the login page in the security.yml configuration file. 
I want to know if is it possible and how to let the user log in each page of the site (e.g. by inserting the login form on top of the page).  This will save a page load and will not bother users. 
Thanks in advance

A:

The best way to do this is to have all your templates extend a base template.  I.E, in all your Twig templates have something like
{% extends 'YourBundle::base.html.twig' %}

In base.html.twig render a controller which renders the login form.  To do this, in base.html.twig do something like:
{% render "YourBundle:Security:loginForm" %}

Then create a controller action, something like:
public function loginFormAction()
{
    $loginForm = //create the form
    return $this->render('YourBundle:Security:loginForm.html.twig', array(
        'form' => $loginForm,
    }
}

And finally in your loginForm.html.twig render the form.