I
I
Ivan Sinyukov2017-10-16 10:06:13
symfony
Ivan Sinyukov, 2017-10-16 10:06:13

Symfony3 how to make Remember me work?

Friends, colleagues welcome!
There is a project on Symfony 3.1.4. There are users, there is a standard authorization and verification form.
In app/config/config.yml

session:
  handler_id:  session.handler.native_file
  save_path: ~
  cookie_lifetime: 2678400 # месяц
  gc_probability: 0
  cookie_path: /

In app/config/security.yml
security:
  encoders:
    AppBundle\Entity\User:
      id: app.custom_password_encoder
    AppBundle\Entity\Project: bcrypt

  role_hierarchy:
    ROLE_ADMIN: [ROLE_USER]

  providers:
    our_users:
      entity: { class: AppBundle\Entity\User, property: email }
    accounts:
      entity: { class: AppBundle\Entity\Project, property: email }

  firewalls:
    api:
      host: ^api
      anonymous: true
      stateless: true
      guard:
        authenticators:
          - 'jwt_token_authenticator'
          - 'project_authenticator'
        entry_point: jwt_token_authenticator

  main:
      pattern: /.*
      anonymous: ~
      guard:
        authenticators:
          - app.security.login_form_authenticator

      form_login:
        login_path: security_login
        always_use_default_target_path: true
        default_target_path: /
        provider: our_users
        remember_me: true

      logout:
        path: /logout

      remember_me:
        secret: '%secret%'
        always_remember_me: true
        lifetime: 2678400
        remember_me_parameter: _remember_me
        path: /
        domain: ~

  access_control:
     . . .

When authorizing, a cookie is set, expiration for a month in advance, everything seems to be fine. But if you update after a while (I honestly don’t know how long), the site asks you to log in again. Cookie disappears.
Why is this happening, please help. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question