wp_setcookie

Sets a cookie for a user who just logged in.

Description

wp_setcookie( (string) $username, (string) $password = '', (constant) $already_md5 = false, (string) $home = '', (string) $siteurl = '', (constant) $remember = false ); 

This function is deprecated.

Parameters (6)

0. $username (string)
The user's username
1. $password — Optional. (string) => ''
The user's password
2. $already_md5 — Optional. (constant) => false
Whether the password has already been through MD5
3. $home — Optional. (string) => ''
Will be used instead of COOKIEPATH if set
4. $siteurl — Optional. (string) => ''
Will be used instead of SITECOOKIEPATH if set
5. $remember — Optional. (constant) => false
Remember that the user is logged in

Usage

  1. if ( !function_exists( 'wp_setcookie' ) ) { 
  2. require_once ABSPATH . WPINC . '/pluggable-deprecated.php'; 
  3.  
  4. // The user's username 
  5. $username = ''; 
  6.  
  7. // Optional. The user's password 
  8. $password = ''; 
  9.  
  10. // Optional. Whether the password has already been through MD5 
  11. $already_md5 = false; 
  12.  
  13. // Optional. Will be used instead of COOKIEPATH if set 
  14. $home = ''; 
  15.  
  16. // Optional. Will be used instead of SITECOOKIEPATH if set 
  17. $siteurl = ''; 
  18.  
  19. // Optional. Remember that the user is logged in 
  20. $remember = false; 
  21.  
  22. // NOTICE! Understand what this does before running. 
  23. $result = wp_setcookie($username, $password, $already_md5, $home, $siteurl, $remember); 
  24.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/pluggable-deprecated.php  
  1. function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) { 
  2. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_set_auth_cookie()' ); 
  3. $user = get_user_by('login', $username); 
  4. wp_set_auth_cookie($user->ID, $remember);