wc_setcookie()WC 1.0

Set a cookie - wrapper for setcookie using WP constants.

Возвращает

null. Ничего.

Использование

wc_setcookie( $name, $value, $expire, $secure, $httponly );
$name(строка) (обязательный)
Name of the cookie being set.
$value(строка) (обязательный)
Value of the cookie.
$expire(int)
Expiry of the cookie.
$secure(true|false)
Whether the cookie should be served only over https.
По умолчанию: false
$httponly(true|false)
Whether the cookie is only accessible over HTTP, not scripting languages like JavaScript. @since 3.6.0.
По умолчанию: false

Код wc_setcookie() WC 6.6.1

function wc_setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
	if ( ! apply_filters( 'woocommerce_set_cookie_enabled', true, $name ,$value, $expire, $secure ) ) {
		return;
	}

	if ( ! headers_sent() ) {
		setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'woocommerce_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
	} elseif ( Constants::is_true( 'WP_DEBUG' ) ) {
		headers_sent( $file, $line );
		trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
	}
}