0

I'm building remember_me functionality in symfony. Instead of tokens being stored in cookies I want to store them in database So, I'm trying to use an option called token_provider but there is not much information detailed on Symfony.com.

I am new to Symfony, can any one share the syntax of "token_provider" in security.yml->firewalls->remember_me?

any help will be appreciated.

Changes I have done

  1. Created a custom service which extends Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider and passed the db connection object from the constructor

    class CustomTokenService extends DoctrineTokenService { public function __construct(EntityManagerInterface $em){ parent::__construct($em->getConnection()); } }

  2. Registered this service in app/config/services.yml

1 Answer 1

0

custom service in services.yml:
token_service: alias:{App}\Bundle\Services\Utilities\CustomTokenService
public: true

In Security.yml:
remember_me:
secret: '%kernel.secret%'
lifetime: 604800 # 1 week in seconds
path: /
domain: ~
remember_me_parameter: _stay_signedin
token_provider: token_service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.