wp_setcookie()WP 1.5.0

Deprecated since 2.5.0. It is no longer supported and may be removed in future releases. Use wp_set_auth_cookie() instead.

Sets a cookie for a user who just logged in. This function is deprecated.

No Hooks.

Returns

null. Nothing (null).

Usage

wp_setcookie( $username, $password, $already_md5, $home, $siteurl, $remember );
$username(string) (required)
The user's username.
$password(string)

The user's password.

It has the attribute #[\SensitiveParameter], which hides the value of the parameter from logs. It is used to protect sensitive data (for example, passwords). Documentation.

Default: ''

$already_md5(true|false)
Whether the password has already been through MD5.
Default: false
$home(string)
Will be used instead of COOKIEPATH if set.
Default: ''
$siteurl(string)
Will be used instead of SITECOOKIEPATH if set.
Default: ''
$remember(true|false)
Remember that the user is logged in.
Default: false

Notes

Changelog

Since 1.5.0 Introduced.
Deprecated since 2.5.0 Use wp_set_auth_cookie()

wp_setcookie() code WP 6.9.1

function wp_setcookie(
	$username,
	#[\SensitiveParameter]
	$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);
}