WC_Site_Tracking::set_tracking_cookiepublic staticWC 9.2.0

Sets a cookie for tracking purposes, but only if tracking is enabled/allowed.

Метод класса: WC_Site_Tracking{}

Хуков нет.

Возвращает

true|false. If setting the cookie was attempted (will be false if tracking is not allowed).

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

$result = WC_Site_Tracking::set_tracking_cookie( $cookie_key, $cookie_value, $expire, $secure, $http_only ): bool;
$cookie_key(строка) (обязательный)
The key of the cookie.
$cookie_value(строка) (обязательный)
The value of the cookie.
$expire(int)
Expiry of the cookie.
$secure(true|false)
Whether the cookie should be served only over https.
По умолчанию: false
$http_only(true|false)
Whether the cookie is only accessible over HTTP.
По умолчанию: false

Список изменений

С версии 9.2.0 Введена.

Код WC_Site_Tracking::set_tracking_cookie() WC 9.9.5

public static function set_tracking_cookie( string $cookie_key, string $cookie_value, int $expire = 0, bool $secure = false, bool $http_only = false ): bool {
	if ( self::is_tracking_enabled() ) {
		wc_setcookie( $cookie_key, $cookie_value, $expire, $secure, $http_only );
		return true;
	}

	return false;
}