Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: auth_cookie_expiration

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
2689      $current_user = wp_get_current_user();
2690      if ( $current_user->ID == $user_id ) {
2691           if ( isset( $plaintext_pass ) ) {
2692                wp_clear_auth_cookie();
2693
2694                // Here we calculate the expiration length of the current auth cookie and compare it to the default expiration.
2695                // If it's greater than this, then we know the user checked 'Remember Me' when they logged in.
2696                $logged_in_cookie = wp_parse_auth_cookie( '', 'logged_in' );
2697                /** This filter is documented in wp-includes/pluggable.php */
2698                $default_cookie_life = apply_filters( 'auth_cookie_expiration', ( 2 * DAY_IN_SECONDS ), $user_id, false );
2699                $remember            = false;
2700                if ( false !== $logged_in_cookie && ( $logged_in_cookie['expiration'] - time() ) > $default_cookie_life ) {
2701                     $remember = true;
2702                }
2703
2704                wp_set_auth_cookie( $user_id, $remember );
2705           }
2706      }
2707