silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

remember me #1562

Closed nimasdj closed 6 years ago

nimasdj commented 6 years ago

I am confused with remember me, when the cookie is set, then what to do when user is coming back in order to authenticate them? How to validate the cookie value or what should I do? _username and _password is a condition that remember me recognizes them to automatically allow user?

eman1986 commented 6 years ago

the firewall will automatically know this, you shouldn't have to do anything except configure the firewall to accept the remember me token

nimasdj commented 6 years ago

I did read https://silex.symfony.com/doc/2.0/providers/remember_me.html and here is my code. I expected a cookie will be set, but I see no REMEMBERME cookie in developper tool. What wrong I did?

$app = new Silex\Application();

$app->register(new Silex\Provider\SecurityServiceProvider());
$app->register(new Silex\Provider\RememberMeServiceProvider());

$app['security.firewalls'] = array(
    'my-firewall' => array(
        'pattern'     => '^/secure$',
        'remember_me' => array(
            'key'                => 'Choose_A_Unique_Random_Key',
            'always_remember_me' => true,
            /* Other options */
        ),
    ),
);
fabpot commented 6 years ago

Closing as support should be done on StackOverflow instead.