login - Extend Cookie with auth_cookie_expiration not working

I was trying to extend the Login Cookie with the following Codefunction expiration_filter($seconds, $user_id, $remember)

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

相关推荐

  • login - Extend Cookie with auth_cookie_expiration not working

    I was trying to extend the Login Cookie with the following Codefunction expiration_filter($seconds, $user_id, $remember)

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信