diff --git a/wp-includes/pluggable-functions.php b/wp-includes/pluggable-functions.php index c5cfa9695..c6cb5cc53 100644 --- a/wp-includes/pluggable-functions.php +++ b/wp-includes/pluggable-functions.php @@ -174,7 +174,7 @@ function wp_redirect($location) { endif; if ( !function_exists('wp_setcookie') ) : -function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') { +function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) { if ( !$already_md5 ) $password = md5( md5($password) ); // Double hash the password in the cookie. @@ -191,12 +191,17 @@ function wp_setcookie($username, $password, $already_md5 = false, $home = '', $s $cookiehash = md5($siteurl); } - setcookie(USER_COOKIE, $username, time() + 31536000, $cookiepath, COOKIE_DOMAIN); - setcookie(PASS_COOKIE, $password, time() + 31536000, $cookiepath, COOKIE_DOMAIN); + if ( $remember ) + $expire = time() + 31536000; + else + $expire = 0; + + setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN); if ( $cookiepath != $sitecookiepath ) { - setcookie(USER_COOKIE, $username, time() + 31536000, $sitecookiepath, COOKIE_DOMAIN); - setcookie(PASS_COOKIE, $password, time() + 31536000, $sitecookiepath, COOKIE_DOMAIN); + setcookie(USER_COOKIE, $username, $expire, $sitecookiepath, COOKIE_DOMAIN); + setcookie(PASS_COOKIE, $password, $expire, $sitecookiepath, COOKIE_DOMAIN); } } endif; diff --git a/wp-login.php b/wp-login.php index 5c4451acf..e3a8fe6ca 100644 --- a/wp-login.php +++ b/wp-login.php @@ -163,6 +163,7 @@ default: if( !empty($_POST) ) { $user_login = $_POST['log']; $user_pass = $_POST['pwd']; + $rememberme = $_POST['rememberme']; $redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $_POST['redirect_to']); } elseif ( !empty($_COOKIE) ) { if (! empty($_COOKIE[USER_COOKIE]) ) @@ -182,8 +183,8 @@ default: $redirect_to = get_settings('siteurl') . '/wp-admin/profile.php'; if ( wp_login($user_login, $user_pass, $using_cookie) ) { - if (! $using_cookie) { - wp_setcookie($user_login, $user_pass); + if ( !$using_cookie) { + wp_setcookie($user_login, $user_pass, false, '', '', $rememberme); } do_action('wp_login', $user_login); wp_redirect($redirect_to); @@ -226,6 +227,9 @@ if ( $error )

+

+