As the title says, how can i increase the login expiration period?

Running a local install it's a little annoying to have to keep logging in, despite the fact i have the browser remember login credentials it's an extra step i have to perform everytime i fire up the local server.

I assume if i increase the cookie expiration period i'll avoid the need to keep logging in(as often).

Have googled and searched the forums, but all i found were unresponded to threads and i'm not in the mood for digging through code to work it out.

I don't need an in-depth answer, just some pointers on suitable hooks(if any exist for this purpose), i can work out the rest from there.

Off to find somewhere cool to sit now, upstairs is roasting hot right now(hot weather here) i think the laptop might just die if i keep it on any longer, i'll be keeping tabs on the question from another system in a cooler area of the house though and looking forward to any pointers you guys have for me.

3 Answers 3


Don't know if this is the best way, but I've been using this in functions.php in my themes:

function keep_me_logged_in_for_1_year( $expirein ) {
   return 31556926; // 1 year in seconds
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );
  • 1
    Looks ideal, i'll report back if not, but i'm pretty sure that's exactly what i'm after, thanks Mark.
    – t31os
    Aug 1, 2011 at 15:55
  • Doesn't actually solve the problem unfortunately(must be a result of the server being started and stopped), but for most installations this should be perfectly fine(so technically is still the correct answer).
    – t31os
    Aug 6, 2011 at 11:18
  • Interesting; I didn't realize it's the same case on my localhost; the cookie doesn't have an expire date. And this would work better in a plugin, anyway, rather than needing to be added to functions.php Aug 7, 2011 at 18:45
  • Better use YEAR_IN_SECONDS which is a constant set in wordpress for such cases.
    – Asaf M
    Jul 21, 2023 at 16:09

this doesn't answer your question specifically, but you can pass your user id to wp_set_auth_cookie() and it will log you in.

edit - and it appears it's pluggable and has a remember parameter that expires the cookie in 14 rather than 2 days.


I know this has been answered and accepted a long time ago but taking into account the comments:

Doesn't actually solve the problem unfortunately...

...And this would work better in a plugin, anyway, rather than needing to be added to functions.php

I thought I would give you a late answer as well. So.

There is a plugin that does exactly what you asked for. "Always Remember Me"

From the description:

The 'Remember Me' checkbox on the login form will be always checked, and instead of logging you in for 14 days, the expiration is set to one year.

As far as local development goes (and this is real cool), by the same author there is the "No Login" plugin.

Skip the login form: every visitor automatically auths as an admin. FOR 'LOCALHOST' TEST SITES only, obviously, like when designing a plugin or a theme and testing it across various browsers.

  • "This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress."
    – O'Rooney
    Nov 17, 2021 at 1:23

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.