WordPress at Your Fingertips
function is not described

wc_setcookie() WC 1.0

Set a cookie - wrapper for setcookie using WP constants.

Hooks from the function


null. Nothing.


wc_setcookie( $name, $value, $expire, $secure, $httponly );
$name(string) (required)
Name of the cookie being set.
$value(string) (required)
Value of the cookie.
Expiry of the cookie.
Whether the cookie should be served only over https.
Default: false
Whether the cookie is only accessible over HTTP, not scripting languages like JavaScript. @since 3.6.0.
Default: false

Code of wc_setcookie() WC 5.8.0

function wc_setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
	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