Skip to content

How To Extend Auto Logout Period In WordPress

When you click on “Remember Me” option on the login page of your WordPress, it’ll keep you logged in for 2 weeks. If you don’t, it’ll keep you login for 2 days. However, you can extend auto logout period in WordPress with this code. Keep in mind that it will affect site’s security by keeping user logged in for too much time.

Just add the following code snippet change the duration of the authentication cookie.

add_filter( 'auth_cookie_expiration', 'custom_login_cookie' );
function custom_login_cookie() {
    return 31536000; // one year in seconds
}Code language: JavaScript (javascript)

The above code will keep you the cookies for a year. You can change the time period by changing return value in above code with your preferred time (in seconds).

Leave a Reply

Your email address will not be published. Required fields are marked *