title: 'Bad Credentials' error in traditional Login form
body: <p>I am new in symfony and trying to develop Login application with help of <a href="http://symfony.com/doc/current/book/security.html" rel="nofollow">Symfony Docs</a>.But 
  I got error on submit event as below </p>
  
  <pre><code>exception 'Symfony\Component\Security\Core\Exception\BadCredentialsException' with message 'Bad credentials' in D:\xampp\htdocs\LoginProject\vendor\symfony\symfony\src\Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider.php:90 Stack trace: #0 D:\xampp\htdocs\LoginProject\app\cache\dev\classes.php(3366): session_start() #1 D:\xampp\htdocs\LoginProject\app\cache\dev\classes.php(3444): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage-&gt;start() #2 D:\xampp\htdocs\LoginProject\app\cache\dev\classes.php(3190): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage-&gt;getBag('attributes') #3 D:\xampp\htdocs\LoginProject\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\ContextListener.php(76): Symfony\Component\HttpFoundation\Session\Session-&gt;get('_security_secur...') #4 D:\xampp\htdocs\LoginProject\app\cache\dev\classes.php(4644): Symfony\Component\Security\Http\Firewall\ContextListener-&gt;handle(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #5 [internal function]: Symfony\Component\Security\Http\Firewall-&gt;onKernelRequest(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher)) #6 D:\xampp\htdocs\LoginProject\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher.php(392): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher)) #7 [internal function]: Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher-&gt;Symfony\Component\HttpKernel\Debug\{closure}(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher)) #8 D:\xampp\htdocs\LoginProject\app\cache\dev\classes.php(2903): call_user_func(Object(Closure), Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher)) #9 D:\xampp\htdocs\LoginProject\app\cache\dev\classes.php(2836): Symfony\Component\EventDispatcher\EventDispatcher-&gt;doDispatch(Array, 'kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #10 D:\xampp\htdocs\LoginProject\app\cache\dev\classes.php(3000): Symfony\Component\EventDispatcher\EventDispatcher-&gt;dispatch('kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #11 D:\xampp\htdocs\LoginProject\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher.php(139): Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch('kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #12 D:\xampp\htdocs\LoginProject\app\bootstrap.php.cache(2900): Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher-&gt;dispatch('kernel.request', Object(Symfony\Component\HttpKernel\Event\GetResponseEvent)) #13 D:\xampp\htdocs\LoginProject\app\bootstrap.php.cache(2883): Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #14 D:\xampp\htdocs\LoginProject\app\bootstrap.php.cache(3022): Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 D:\xampp\htdocs\LoginProject\app\bootstrap.php.cache(2303): Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 D:\xampp\htdocs\LoginProject\web\app_dev.php(28): Symfony\Component\HttpKernel\Kernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request)) #17 {main}
  </code></pre>
  
  <p>please check my code below</p>
  
  <p><strong>Security.yml</strong></p>
  
  <pre><code>   secured_area:
          pattern:    ^/
          anonymous: ~
          form_login:
              check_path: /login_check
              login_path: login_login_homepage
  
          logout:
              path:   login_login_logout
              target: /
              invalidate_session:   true
  
          #anonymous: ~
          #http_basic:
          #    realm: "Secured Demo Area"
  
  access_control:
      #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
       - { path: ^/admin/users, roles: ROLE_SUPER_ADMIN }
       - { path: ^/admin, roles: ROLE_ADMIN }
       - { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: /user, roles: ROLE_USER }
       - { path: /.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
  </code></pre>
  
  <p><strong>Routing.yml</strong></p>
  
  <pre><code>login_login_homepage:
      pattern:  /login
      defaults: { _controller: LoginLoginBundle:Default:login }
  
  check_login:
      pattern: /login_check
  </code></pre>
  
  <p><strong>DefaultController.php</strong></p>
  
  <pre><code>public function loginAction(Request $request){
           $session = $request-&gt;getSession();
  
         if($request-&gt;attributes-&gt;has(SecurityContext::AUTHENTICATION_ERROR)){
             $error = $request-&gt;attributes-&gt;get(
                  SecurityContext::AUTHENTICATION_ERROR
             );
         }else{
             $error = $session-&gt;get(SecurityContext::AUTHENTICATION_ERROR);
             $session-&gt;remove(SecurityContext::AUTHENTICATION_ERROR);
         }
  
  
         $login = $this-&gt;check_loginAction($request-&gt;get('username'),$request-&gt;get('password'));
         if($login){
             return $this-&gt;render(
                  'LoginLoginBundle:Default:Login.html.twig',
                  array(
                      'last_username'=&gt;$session-&gt;get(SecurityContext::LAST_USERNAME)
                  )
          );
         }else{
          return $this-&gt;render(
                  'LoginLoginBundle:Default:Login.html.twig',
                  array(
                      'last_username'=&gt;'Error',
                      'error'=&gt;$error,
                  )
          );
        }
      }
  
      public function check_loginAction($username,$password){
  
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $respondary = $em-&gt;getRepository('LoginLoginBundle:Login');
  
              $login = $respondary-&gt;findOneBy(array('user' =&gt; $username, 'pass' =&gt; $password));
              if($login){
                  return true;
              }else{
                  return false;
                  //$this-&gt;render('LoginLoginBundle:Default:Login.html.twig', array('error' =&gt; 'Login Failed'));
              }
  
      }
  </code></pre>
  
  <p>Please help me out it.</p>