Change Cookie Expire Time WordPress

add_filter('auth_cookie_expiration', 'expiration_filter', 99, 3);
function expiration_filter($seconds, $user_id, $remember){

 //if "remember me" is checked;
 if ( $remember ) {
 //WP defaults to 2 weeks;
 $expiration = 14*24*60*60; //UPDATE HERE in seconds;
 } else {
 //WP defaults to 48 hrs/2 days;
 $expiration = 2*24*60*60; //UPDATE HERE in seconds;
 }

 return $expiration;
}

Leave a Comment