How to create Remember Me

Hi… everyone
I am working on login system so I used Authentication/Authorization plugin for handle login Authentication.

Application.php middlware for cookie

->add(new EncryptedCookieMiddleware(
                // Names of cookies to protect
                ['CookieAuth', 'secrets', 'protected'],

Application.php in getAuthenticationService Method

$service->loadAuthenticator('Authentication.Cookie', [
            'fields' => $fields,
            'loginUrl' => '/accounts/login',


 $result = $this->Authentication->getResult();
        // If the user is logged in send them away.
        if ($result->isValid()) {
            $Users = $this->getTableLocator()->get('Users');
            $user  = $Users->get($result->getData()->userkeyid);
            $user->login_time = DateTime::now();

                $target = '/users';
            return $this->redirect($target);

login.php file in Template

<?= $this->Form->create() ?>
        <div class="mb-3">
            <?= $this->Form->control('email', ['class' => 'form-control', 'autocomplete' => "off"]) ?>
        <div class="mb-3">
            <?= $this->Form->control('password', ['class' => 'form-control', 'autocomplete' => "off"]) ?>
        <div class="mb-3">
            <?= $this->Form->control(' remember_me', ['type' => 'checkbox', 'class' => 'form-check-input']); ?>
        <div class="mb-3">
            <?= $this->Form->submit('Login', ['class' => 'form-control btn btn-primary rounded-0']) ?>
        <?= $this->Form->end() ?>

here you can see… i just set remeber_me field but it does not work if user click on remember me checkbox…

can you please explain how does i do this? any code Example for remember me?

Is it as simple as the extra space you have before “remember_me” in the form?