1

I recently discovered that if I don't disconnect myself from WordPress, my session could last for more than a day.

I wondered what could I do to set a maximum time of inactivity on the site, after which the user would be logged out. I guess that has something to do with the validity of a cookie, but I'm not sure about that. How can I force a disconnect after a certain amount of time?

1

By default, the "Remember Me" checkbox makes you get remembered for 14 days. This is filterable though.

add below code in your theme functions.php where 31556926 = 1 year in seconds

This code will change that value:

add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );

function keep_me_logged_in_for_1_year( $expirein ) {
    return 31556926; // 1 year in seconds
}
  • While this may answer the question do you mind explaining what is happening in your code for others. if you did, I would be more prone to upvote your answer. – DᴀʀᴛʜVᴀᴅᴇʀ Nov 16 '15 at 18:59

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.