yith_setcookie

Create a cookie.

Description

yith_setcookie( (string) $name, (array) $value = array(), (null) $time = null ); 

Parameters (3)

0. $name (string)
The name.
1. $value — Optional. (array) => array()
The value.
2. $time — Optional. (null) => null
The time.

Usage

  1. if ( !function_exists( 'yith_setcookie' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yith-woocommerce-wishlist/includes/functions.yith-wcwl.php'; 
  3.  
  4. // The name. 
  5. $name = ''; 
  6.  
  7. // The value. 
  8. $value = array(); 
  9.  
  10. // The time. 
  11. $time = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = yith_setcookie($name, $value, $time); 
  15.  

Defined (1)

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

/includes/functions.yith-wcwl.php  
  1. function yith_setcookie( $name, $value = array(), $time = null ) { 
  2. $time = $time != null ? $time : time() + apply_filters( 'yith_wcwl_cookie_expiration', 60 * 60 * 24 * 30 ); 
  3.  
  4. $value = json_encode( stripslashes_deep( $value ) ); 
  5. $expiration = apply_filters( 'yith_wcwl_cookie_expiration_time', $time ); // Default 30 days 
  6.  
  7. $_COOKIE[ $name ] = $value; 
  8. wc_setcookie( $name, $value, $expiration, false );