prosource

WordPress에서 세션 만료 시간을 변경하는 방법

probook 2023. 2. 8. 18:05
반응형

WordPress에서 세션 만료 시간을 변경하는 방법

WordPress 사이트에서 사용자(admin)가 15분간 비활성화된 경우 세션을 종료하고 싶습니다.

WordPress의 기본 세션 만료 시간과 기본 만료 시간을 변경하는 방법을 알려 주시겠습니까?

테마의 함수에 이 코드를 추가하기만 하면 됩니다.php:

add_filter('auth_cookie_expiration', 'my_expiration_filter', 99, 3);
function my_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;
    } else {
        //WP defaults to 48 hrs/2 days;
        $expiration = 2*24*60*60; //UPDATE HERE;
    }

    //http://en.wikipedia.org/wiki/Year_2038_problem
    if ( PHP_INT_MAX - time() < $expiration ) {
        //Fix to a little bit earlier!
        $expiration =  PHP_INT_MAX - time() - 5;
    }

    return $expiration;
}

언급URL : https://stackoverflow.com/questions/9191359/how-to-change-session-expire-time-in-wordpress

반응형