wp_parse_auth_cookie example

// Update the cookies if the password changed.     $current_user = wp_get_current_user();
    if ( $current_user->ID == $user_id ) {
        if ( isset( $plaintext_pass ) ) {
            wp_clear_auth_cookie();

            /* * Here we calculate the expiration length of the current auth cookie and compare it to the default expiration. * If it's greater than this, then we know the user checked 'Remember Me' when they logged in. */
            $logged_in_cookie = wp_parse_auth_cookie( '', 'logged_in' );
            /** This filter is documented in wp-includes/pluggable.php */
            $default_cookie_life = apply_filters( 'auth_cookie_expiration', ( 2 * DAY_IN_SECONDS )$user_id, false );
            $remember            = false;
            if ( false !== $logged_in_cookie && ( $logged_in_cookie['expiration'] - time() ) > $default_cookie_life ) {
                $remember = true;
            }

            wp_set_auth_cookie( $user_id$remember );
        }
    }

    

    function wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
        $cookie_elements = wp_parse_auth_cookie( $cookie$scheme );
        if ( ! $cookie_elements ) {
            /** * Fires if an authentication cookie is malformed. * * @since 2.7.0 * * @param string $cookie Malformed auth cookie. * @param string $scheme Authentication scheme. Values include 'auth', 'secure_auth', * or 'logged_in'. */
            do_action( 'auth_cookie_malformed', $cookie$scheme );
            
Home | Imprint | This part of the site doesn't use cookies.