WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp setcookie

Contents

Description

This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.

Sets a cookie for a user who just logged in.

This function is deprecated. Use wp_set_auth_cookie() instead.

Usage

<?php wp_setcookie$username$password$already_md5$home$siteurl$remember ?>

Parameters

$username
(string) (required) The user's username
Default: None
$password
(string) (optional) The user's password
Default: ''
$already_md5
(boolean) (optional) Whether the password has already been through MD5
Default: false
$home
(string) (optional) Will be used instead of COOKIEPATH if set
Default: ''
$siteurl
(string) (optional) Will be used instead of SITECOOKIEPATH if set
Default: ''
$remember
(boolean) (optional) Remember that the user is logged in
Default: false

Return Values

void 
This function doesn't return anything.

Examples

Notes

  • This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead.
  • This function is deprecated. Use wp_set_auth_cookie() instead.

Change Log

  • Since: 1.5
  • Deprecated: 2.5.0

Source File

wp_setcookie() is located in wp-includes/pluggable.php.

Related