Warning: This function has been deprecated. Use wp_set_auth_cookie() instead.

wp_setcookie() WordPress Function

The wp_setcookie function sets a cookie for a user. The function takes three arguments: the name of the cookie, the value of the cookie, and the expiration date of the cookie. The expiration date is optional, and if omitted, the cookie will expire when the browser is closed.

wp_setcookie( string $username, string $password = '', bool $already_md5 = false, string $home = '', string $siteurl = '', bool $remember = false ) #

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


Description

Top ↑

See also


Top ↑

Parameters

$username

(string)(Required)The user's username

$password

(string)(Optional) The user's password

Default value: ''

$already_md5

(bool)(Optional) Whether the password has already been through MD5

Default value: false

$home

(string)(Optional) Will be used instead of COOKIEPATH if set

Default value: ''

$siteurl

(string)(Optional) Will be used instead of SITECOOKIEPATH if set

Default value: ''

$remember

(bool)(Optional) Remember that the user is logged in

Default value: false


Top ↑

Source

File: wp-includes/pluggable-deprecated.php

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);
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.0Use wp_set_auth_cookie()
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.