I was trying to extend the Login Cookie with the following Code
function expiration_filter($seconds, $user_id, $remember){
//if "remember me" is checked;
if ( $remember ) {
//WP defaults to 2 weeks; 14*24*60*60
$expiration = 10*365*24*60*60; //10 Yrs;
} else {
//WP defaults to 48 hrs/2 days; 2*24*60*60
$expiration = 2*24*60*60; //UPDATE HERE;
}
//
if ( PHP_INT_MAX - time() < $expiration ) {
//Fix to a little bit earlier!
$expiration = PHP_INT_MAX - time() - 5;
}
return $expiration;
}
add_filter('auth_cookie_expiration', 'expiration_filter', 99, 3);
The Cookie is set to a date in 10 years (2029) which seems fine, but after 2 weeks the user gets logged out. Maybe I missed something in the Code or there is an extra Hook for everything beyond 2 weeks?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745474269a4629272.html
评论列表(0条)