title: Get username in Symfony (in Twig) on page, which is accessible to anonymous users
body: <p>Is there a way to access username of the logged user on page, which is accessible to anonym users in Symfony 2.6.1?</p>
  
  <p>Example:
  I have main page, where is link to login and if there is a user logged in, I want to display his username as a link to his account instead of the login link.</p>
  
  <p>If I use <code>{{ app.user.username }}</code> it will display error </p>
  
  <pre><code>Impossible to access an attribute ("username") on a NULL variable ("")
  </code></pre>
  
  <p>because <code>app.user</code> is null object on pages with <code>security: false</code> defined is <em>security.yml</em>. It will work only on pages, which needs to be under firewall with no <code>security: false</code>.</p>