mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
wp_setcookie() and wp_clearcookie(). Set cookies for both siteurl and home if they are not the same. Update cookies whenever home or siteurl change.
git-svn-id: https://develop.svn.wordpress.org/trunk@2107 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1628,4 +1628,37 @@ function add_magic_quotes($array) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
function wp_setcookie($username, $password, $already_md5 = false, $home = '', $siteurl = '') {
|
||||
if ( ! $already_md5)
|
||||
$password = md5(md5($password)); // Double hash the password in the cookie.
|
||||
|
||||
if (empty($home))
|
||||
$cookiepath = COOKIEPATH;
|
||||
else
|
||||
$cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' );
|
||||
|
||||
if (empty($siteurl)) {
|
||||
$sitecookiepath = SITECOOKIEPATH;
|
||||
$cookiehash = COOKIEHASH;
|
||||
} else {
|
||||
$sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );
|
||||
$cookiehash = md5($siteurl);
|
||||
}
|
||||
|
||||
setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $cookiepath);
|
||||
setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $cookiepath);
|
||||
|
||||
if ( $cookiepath != $sitecookiepath ) {
|
||||
setcookie('wordpressuser_'. $cookiehash, $username, time() + 31536000, $sitecookiepath);
|
||||
setcookie('wordpresspass_'. $cookiehash, $password, time() + 31536000, $sitecookiepath);
|
||||
}
|
||||
}
|
||||
|
||||
function wp_clearcookie() {
|
||||
setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);
|
||||
setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, COOKIEPATH);
|
||||
setcookie('wordpressuser_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);
|
||||
setcookie('wordpresspass_' . COOKIEHASH, ' ', time() - 31536000, SITECOOKIEPATH);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user