wc_session_use_secure_cookie filter
This commit is contained in:
parent
c5f7d046b7
commit
7810d78cde
|
@ -76,7 +76,7 @@ class WC_Session_Handler extends WC_Session {
|
||||||
$cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
|
$cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
|
||||||
|
|
||||||
// Set the cookie
|
// Set the cookie
|
||||||
wc_setcookie( $this->_cookie, $cookie_value, $this->_session_expiration );
|
wc_setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, apply_filters( 'wc_session_use_secure_cookie', false ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,10 +365,11 @@ function wc_print_js() {
|
||||||
* @param string $name Name of the cookie being set
|
* @param string $name Name of the cookie being set
|
||||||
* @param string $value Value of the cookie
|
* @param string $value Value of the cookie
|
||||||
* @param integer $expire Expiry of the cookie
|
* @param integer $expire Expiry of the cookie
|
||||||
|
* @param string $secure Whether the cookie should be served only over https
|
||||||
*/
|
*/
|
||||||
function wc_setcookie( $name, $value, $expire = 0 ) {
|
function wc_setcookie( $name, $value, $expire = 0, $secure = false ) {
|
||||||
if ( ! headers_sent() ) {
|
if ( ! headers_sent() ) {
|
||||||
setcookie( $name, $value, $expire, COOKIEPATH, COOKIE_DOMAIN, false );
|
setcookie( $name, $value, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
|
||||||
} elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
} elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||||
trigger_error( "Cookie cannot be set - headers already sent", E_USER_NOTICE );
|
trigger_error( "Cookie cannot be set - headers already sent", E_USER_NOTICE );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue