# Keep "Remember Me" Logins for 30 Days

> Extends the login cookie to 30 days when "Remember Me" is ticked. Sessions without it keep the normal two-day lifetime.

- Type: PHP
- Runs: Run everywhere
- Category: [Login](https://wpide.com/library/category/login/)
- Tags: login, session, cookie
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/longer-remember-me-session/

## Code

```php
add_filter( 'auth_cookie_expiration', function ( $expiration, $user_id, $remember ) {
    return $remember ? 30 * DAY_IN_SECONDS : $expiration;
}, 10, 3 );
```

## Notes

Change 30 to the number of days you want.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep "Remember Me" Logins for 30 Days" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
