wp_set_auth_cookie example

global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie().     $auth_secure_cookie = $secure_cookie;

    add_filter( 'authenticate', 'wp_authenticate_cookie', 30, 3 );

    $user = wp_authenticate( $credentials['user_login']$credentials['user_password'] );

    if ( is_wp_error( $user ) ) {
        return $user;
    }

    wp_set_auth_cookie( $user->ID, $credentials['remember']$secure_cookie );
    /** * Fires after the user has successfully logged in. * * @since 1.5.0 * * @param string $user_login Username. * @param WP_User $user WP_User object of the logged-in user. */
    do_action( 'wp_login', $user->user_login, $user );
    return $user;
}


function wp_setcookie($username$password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
    _deprecated_function( __FUNCTION__, '2.5.0', 'wp_set_auth_cookie()' );
    $user = get_user_by('login', $username);
    wp_set_auth_cookie($user->ID, $remember);
}
else :
    _deprecated_function( 'wp_setcookie', '2.5.0', 'wp_set_auth_cookie()' );
endif;

if ( !function_exists('wp_clearcookie') ) :
/** * Clears the authentication cookie, logging the user out. This function is deprecated. * * @since 1.5.0 * @deprecated 2.5.0 Use wp_clear_auth_cookie() * @see wp_clear_auth_cookie() */
Home | Imprint | This part of the site doesn't use cookies.