WordPress at Your Fingertips
function is not described

WC_Session_Handler::set_customer_session_cookie() public WC 1.0

Sets the session cookie on-demand (usually after adding an item to the cart).

Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.

Warning: Cookies will only be set if this is called before the headers are sent.

{} It's a method of the class: WC_Session_Handler{}

No Hooks.

Return

null. Nothing.

Usage

$WC_Session_Handler = new WC_Session_Handler();
$WC_Session_Handler->set_customer_session_cookie( $set );
$set(true|false) (required)
Should the session cookie be set.

Code of WC_Session_Handler::set_customer_session_cookie() WC 5.9.0

public function set_customer_session_cookie( $set ) {
	if ( $set ) {
		$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
		$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
		$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
		$this->_has_cookie = true;

		if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
			wc_setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
		}
	}
}