Symfony2 "This authentication method requires a session error" when checking login
I am trying to implement a simple login form following the instructions in the Symfony book, but I am stuck on login. Whenever I try to log in, I get the error "This authentication method requires a session" created from AbstractAuthenticationListener :: handle. I searched the Symfony and Google book and cookbook but didn't find an answer or even some related problem.
Is this a misunderstanding in the book, or perhaps a misconfiguration of my server?
If you need a code extract, don't mind asking ...
security.yml
security:
encoders:
Common\Bundle\UserBundle\Entity\User:
algorithm: bcrypt
cost: 10
providers:
main:
entity: { class: CommonUserBundle:User }
firewalls:
main:
pattern: ^/
provider: main
anonymous: ~
simple_form:
authenticator: simple_authenticator
login_path: /Connexion
check_path: /Connexion/verifier
logout:
path: /Deconnexion
target: /
remember_me:
key: "%secret%"
lifetime: 2592000
path: /
domain: ~
config.yml
framework:
secret: "%secret%"
fragments: { path: /_fragment }
router:
resource: "%kernel.root_dir%/config/routing.yml"
validation:
enable_annotations: true
templating:
engines: ['twig']
default_locale: "%locale%"
http_method_override: true
source to share
You need to enable PHP sessions in order for users to register. Your file config.yml
may appear to be not included, add a section session
inside the root level framework
:
Here is the default configuration:
framework:
# ...
session: ~
Take a look at the official documentation for how to set up session storage: http://symfony.com/doc/current/reference/configuration/framework.html#session
source to share