I have been trying to implement a simple form login following instructions in Symfony's book but I'm stuck at login. Whenever I try to login I get a "This authentication method requires a session" error thrown from AbstractAuthenticationListener::handle. I've searched Symfony's book and cookbook and Google but found no answer or even some related issue.
Is this me misunderstanding something in the book or maybe a misconfiguration of my server?
If you need code extract don't mind to ask...
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
You need to enable PHP sessions to keep users logged. Your config.yml
file lets appear it's not enabled, add a session
section inside framework
root level :
Here is default config :
framework:
# ...
session: ~
Have a look to the official documentation to learn how to configure session storage : http://symfony.com/doc/current/reference/configuration/framework.html#session
For Symfony 4
Edit config/packages/framework.yaml
And add
framework:
session:
handler_id: ~
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With