Not sure if this is a bug or by design, but it's damn annoying. Every so often, more so after updating the core, while in the admin section, I get booted out with the infamous "Your session has expired" message. Strange in itself since apparently WP doesn't use sessions. The login prompt comes with a "remember me" checkbox, why isn't it remembering? I guess there's a distinction between "remember me" and "keep me logged in" here. I've disabled all plugins, deletes cookies, tried other browsers and even yelled at my screen, but I keep getting booted out.

Does WP set a no activity time limit in the admin section? Could somebody explain what exactly WP is doing to keep users logged in.

  • I have no direct answer, however, please enable debugging in WordPress, to see, if anything is weird with your particular installation! Sep 17 '13 at 5:38
  • @PothiKalimuthu Already done and I can't see anything out of the ordinary.
    – Twifty
    Sep 17 '13 at 6:11

By default, WordPress makes your login session cookie expire in 48 hours (or on browser close), or 14 days if you check the “Remember Me” box.

Maybe you have some plugins which force your login cookie to expire.

You could manually add the code below on your functions.php to extend your cookie expiry to whatever timeframe you like. You can, in essence, stop WordPress from ever logging you out by changing the number of seconds to be a much higher number.

add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );
function keep_me_logged_in_for_1_year( $expirein ) {
    return YEAR_IN_SECONDS; // 1 year in seconds

Or you can also use this plugin to change the time limit: Configure Login Timeout

Hope that helps!!

  • starting with 4.0 (IIRC) wordpress do use session tracking, and cookie expiry is only partial explanation/solution at best Apr 25 '17 at 5:43
  • Note that if you try this and it doesn't seem to work, when logging in the user must check "remember me" for this to take effect. Otherwise the cookie is set until the browser session ends.
    – Nathan
    Apr 7 '20 at 19:43
  • User WordPress constant YEAR_IN_SECONDS May 12 '20 at 7:03
  • 3
    Does it still work now? In 2021? Mar 16 '21 at 11:46
  • @MukeshwarSingh do not post comments as full answers, you will be auto-banned by the anti-spam system. I've moved the answer to comments, but having 1 reputation is not an excuse. You've already got an automated flag against your account because of it
    – Tom J Nowell
    Mar 16 '21 at 12:10

This is the code that I added in my child theme to keep user logged in for 2 weeks on my website:


‘keep_me_logged_in_for_2_week’ );

function keep_me_logged_in_for_2_week( $expirein ) {

return WEEK_IN_SECONDS; // 2 week in seconds

  • But WEEK_IN_SECONDS is one week not two.
    – Rup
    Jan 12 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.