WC_Session_Handler::set_customer_session_cookie()
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.
Метод класса: WC_Session_Handler{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WC_Session_Handler = new WC_Session_Handler(); $WC_Session_Handler->set_customer_session_cookie( $set );
- $set(true|false) (обязательный)
- Should the session cookie be set.
Код WC_Session_Handler::set_customer_session_cookie() WC Session Handler::set customer session cookie WC 8.7.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 ); } } }