ID; } endif; if ( !function_exists('wp_generate_auth_cookie') ) : /** * wp_generate_auth_cookie() - Generate authentication cookie contents * * @since 2.5 * @uses apply_filters() Calls 'auth_cookie' hook on $cookie contents, User ID * and expiration of cookie. * * @param int $user_id User ID * @param int $expiration Cookie expiration in seconds * @return string Authentication cookie contents */ function wp_generate_auth_cookie($user_id, $expiration) { $user = get_userdata($user_id); $key = wp_hash($user->user_login . '|' . $expiration); $hash = hash_hmac('md5', $user->user_login . '|' . $expiration, $key); $cookie = $user->user_login . '|' . $expiration . '|' . $hash; return apply_filters('auth_cookie', $cookie, $user_id, $expiration); } endif; if ( !function_exists('wp_set_auth_cookie') ) : /** * wp_set_auth_cookie() - Sets the authentication cookies based User ID * * The $remember parameter increases the time that the cookie will * be kept. The default the cookie is kept without remembering is * two days. When $remember is set, the cookies will be kept for * 14 days or two weeks. * * @since 2.5 * * @param int $user_id User ID * @param bool $remember Whether to remember the user or not */ function wp_set_auth_cookie($user_id, $remember = false) { if ( $remember ) { $expiration = $expire = time() + 1209600; } else { $expiration = time() + 172800; $expire = 0; } $cookie = wp_generate_auth_cookie($user_id, $expiration); do_action('set_auth_cookie', $cookie, $expire); setcookie(AUTH_COOKIE, $cookie, $expire, COOKIEPATH, COOKIE_DOMAIN); if ( COOKIEPATH != SITECOOKIEPATH ) setcookie(AUTH_COOKIE, $cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN); } endif; if ( !function_exists('wp_clear_auth_cookie') ) : /** * wp_clear_auth_cookie() - Deletes all of the cookies associated with authentication * * @since 2.5 */ function wp_clear_auth_cookie() { setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); // Old cookies setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN); setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN); } endif; ?>