On this page
wp_setcookie( string $username, string $password = '', bool $already_md5 = false, string $home = '', string $siteurl = '', bool $remember = false )
This function has been deprecated. Use wp_set_auth_cookie() instead.
Sets a cookie for a user who just logged in. This function is deprecated.
Description
See also
Parameters
$usernamestring Required-
The user's username
$passwordstring Optional-
The user's password
Default:
'' $already_md5bool Optional-
Whether the password has already been through MD5
Default:
false $homestring Optional-
Will be used instead of COOKIEPATH if set
Default:
'' $siteurlstring Optional-
Will be used instead of SITECOOKIEPATH if set
Default:
'' $rememberbool Optional-
Remember that the user is logged in
Default:
false
Source
File: wp-includes/pluggable-deprecated.php. View all references
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);
}
Related
Uses
| Uses | Description |
|---|---|
| wp_set_auth_cookie() wp-includes/pluggable.php | Sets the authentication cookies based on user ID. |
| get_user_by() wp-includes/pluggable.php | Retrieves user info by a given field. |
| _deprecated_function() wp-includes/functions.php | Marks a function as deprecated and inform when it has been used. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Use wp_set_auth_cookie() |
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_setcookie