
If you check “Stay logged in” when you log in (see image), WordPress will allow you to work longer in the WordPress backend without having to log in again.
If this checkmark is set, the lifetime of the authentication cookie is increased. However, the time is only extended by about half a month. If you want to stay logged in longer, for example because you want to work with WordPress every day, the following solution is available:
add_filter( 'auth_cookie_expiration', 'cwhf_extend_auth_cookie_to_1_year' );
function cwhf_extend_auth_cookie_to_1_year( $expirein ) {
return 31556926; // 1 year in seconds
}
The above code must be added to the WordPress code. This is done via the Code Snippets plugin, the functions.php or a