Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Allow Remember Me cookie time to be overriden #39186

Conversation

JamesFreeman
Copy link
Contributor

We want to restrict how long a remember-me token will exist for certain guards. For usual web users, we want to allow them to be logged in forever, but for staff members, we want to expire the remember me token after 30 days.

With this PR, I've made it so you can add rememberMeTokenDuration to the guard in config/auth.php. If you do not provide this, it will maintain the same cookie expiration date which is 5 years.

@JamesFreeman JamesFreeman marked this pull request as draft October 13, 2021 14:25
@JamesFreeman JamesFreeman marked this pull request as ready for review October 13, 2021 14:33
@taylorotwell taylorotwell merged commit 9110b23 into laravel:8.x Oct 14, 2021
@JamesFreeman JamesFreeman deleted the feature/add_ability_to_change_remember_me_time branch October 14, 2021 15:41
@bryceandy
Copy link

I've made it so you can add rememberMeTokenDuration to the guard in config/auth.php.

Since rememberMeTokenDuration is renamed to remember, is this the allowed syntax?

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
        'remember' => 43200,
    ],
    // ...
],

@JamesFreeman
Copy link
Contributor Author

Hey @bryceandy, this is how I've got mine configured:

'guards' => [
     //...
     'admin' => [
            'driver' => 'session',
            'provider' => 'admin',
            'remember' => now()->addDays(30)->diffInMinutes(),
     ],
]

I'll send in a PR to docs, this evening 👍

levinuss added a commit to openmultiplechoice/openmultiplechoice that referenced this pull request Apr 16, 2024
Adds an expiration of 7 days to the `remember_me` cookie.
laravel/framework#39186
schu pushed a commit to openmultiplechoice/openmultiplechoice that referenced this pull request Apr 19, 2024
Adds an expiration of 7 days to the `remember_me` cookie.
laravel/framework#39186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants