From 97a426b19ce5f8560cc3a23c1aac065905073d07 Mon Sep 17 00:00:00 2001 From: matt Date: Sat, 23 Jul 2005 06:56:59 +0000 Subject: [PATCH] Remember me button on login, fixes #379 git-svn-id: http://svn.automattic.com/wordpress/trunk@2733 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable-functions.php | 15 ++++++++++----- wp-login.php | 8 ++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) 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 )

+

+