2013-01-15 19:51:19 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Handle data for the current customers session.
|
2015-10-07 13:47:29 +00:00
|
|
|
* Implements the WC_Session abstract class.
|
2013-01-15 19:51:19 +00:00
|
|
|
*
|
2015-10-07 13:47:29 +00:00
|
|
|
* From 2.5 this uses a custom table for session storage. Based on https://github.com/kloon/woocommerce-large-sessions.
|
2013-01-15 19:51:19 +00:00
|
|
|
*
|
2015-10-07 13:58:13 +00:00
|
|
|
* @class WC_Session_Handler
|
|
|
|
* @version 2.5.0
|
|
|
|
* @package WooCommerce/Classes
|
2017-12-15 14:34:04 +00:00
|
|
|
*/
|
|
|
|
|
2018-03-21 03:18:01 +00:00
|
|
|
defined( 'ABSPATH' ) || exit;
|
2017-12-15 14:34:04 +00:00
|
|
|
|
|
|
|
/**
|
2018-03-21 03:18:01 +00:00
|
|
|
* Session handler class.
|
2013-01-15 19:51:19 +00:00
|
|
|
*/
|
|
|
|
class WC_Session_Handler extends WC_Session {
|
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
/**
|
|
|
|
* Cookie name used for the session.
|
|
|
|
*
|
|
|
|
* @var string cookie name
|
|
|
|
*/
|
2017-12-04 14:10:35 +00:00
|
|
|
protected $_cookie;
|
2013-01-15 19:51:19 +00:00
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
/**
|
|
|
|
* Stores session expiry.
|
|
|
|
*
|
|
|
|
* @var string session due to expire timestamp
|
|
|
|
*/
|
2017-12-04 14:10:35 +00:00
|
|
|
protected $_session_expiring;
|
2013-01-16 11:05:50 +00:00
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
/**
|
|
|
|
* Stores session due to expire timestamp.
|
|
|
|
*
|
|
|
|
* @var string session expiration timestamp
|
|
|
|
*/
|
2017-12-04 14:10:35 +00:00
|
|
|
protected $_session_expiration;
|
2013-01-15 19:51:19 +00:00
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
/**
|
|
|
|
* True when the cookie exists.
|
|
|
|
*
|
|
|
|
* @var bool Based on whether a cookie exists.
|
|
|
|
*/
|
2017-12-04 14:10:35 +00:00
|
|
|
protected $_has_cookie = false;
|
2014-05-08 09:36:19 +00:00
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
/**
|
|
|
|
* Table name for session data.
|
|
|
|
*
|
|
|
|
* @var string Custom session table name
|
|
|
|
*/
|
2017-12-04 14:10:35 +00:00
|
|
|
protected $_table;
|
2015-10-07 13:47:29 +00:00
|
|
|
|
2013-01-15 19:51:19 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Constructor for the session class.
|
2013-01-15 19:51:19 +00:00
|
|
|
*/
|
|
|
|
public function __construct() {
|
2017-05-10 19:46:43 +00:00
|
|
|
$this->_cookie = apply_filters( 'woocommerce_cookie', 'wp_woocommerce_session_' . COOKIEHASH );
|
2017-12-15 14:34:04 +00:00
|
|
|
$this->_table = $GLOBALS['wpdb']->prefix . 'woocommerce_sessions';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init hooks and session data.
|
|
|
|
*
|
|
|
|
* @since 3.3.0
|
|
|
|
*/
|
|
|
|
public function init() {
|
2019-02-04 15:48:59 +00:00
|
|
|
$this->init_session_cookie();
|
|
|
|
|
|
|
|
add_action( 'woocommerce_set_cart_cookies', array( $this, 'set_customer_session_cookie' ), 10 );
|
|
|
|
add_action( 'shutdown', array( $this, 'save_data' ), 20 );
|
|
|
|
add_action( 'wp_logout', array( $this, 'destroy_session' ) );
|
|
|
|
|
|
|
|
if ( ! is_user_logged_in() ) {
|
|
|
|
add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup cookie and customer ID.
|
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*/
|
|
|
|
public function init_session_cookie() {
|
2017-12-15 14:34:04 +00:00
|
|
|
$cookie = $this->get_session_cookie();
|
2013-01-15 19:51:19 +00:00
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
if ( $cookie ) {
|
2013-01-15 19:51:19 +00:00
|
|
|
$this->_customer_id = $cookie[0];
|
2013-01-16 11:05:50 +00:00
|
|
|
$this->_session_expiration = $cookie[1];
|
|
|
|
$this->_session_expiring = $cookie[2];
|
2014-05-08 09:36:19 +00:00
|
|
|
$this->_has_cookie = true;
|
2019-03-12 16:36:15 +00:00
|
|
|
$this->_data = $this->get_session_data();
|
|
|
|
|
|
|
|
// If the user logs in, update session.
|
|
|
|
if ( is_user_logged_in() && get_current_user_id() !== $this->_customer_id ) {
|
|
|
|
$this->_customer_id = get_current_user_id();
|
|
|
|
$this->_dirty = true;
|
|
|
|
$this->save_data();
|
|
|
|
$this->set_customer_session_cookie( true );
|
|
|
|
}
|
2013-01-15 19:51:19 +00:00
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
// Update session if its close to expiring.
|
2013-01-16 11:05:50 +00:00
|
|
|
if ( time() > $this->_session_expiring ) {
|
|
|
|
$this->set_session_expiration();
|
2015-10-07 13:47:29 +00:00
|
|
|
$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
|
2013-01-15 19:51:19 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-01-16 11:05:50 +00:00
|
|
|
$this->set_session_expiration();
|
2013-01-15 19:51:19 +00:00
|
|
|
$this->_customer_id = $this->generate_customer_id();
|
2019-03-12 16:36:15 +00:00
|
|
|
$this->_data = $this->get_session_data();
|
2013-01-15 19:51:19 +00:00
|
|
|
}
|
2015-10-07 13:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Sets the session cookie on-demand (usually after adding an item to the cart).
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* Warning: Cookies will only be set if this is called before the headers are sent.
|
2017-05-15 11:50:52 +00:00
|
|
|
*
|
2017-12-15 14:34:04 +00:00
|
|
|
* @param bool $set Should the session cookie be set.
|
2015-10-07 13:58:13 +00:00
|
|
|
*/
|
|
|
|
public function set_customer_session_cookie( $set ) {
|
|
|
|
if ( $set ) {
|
2015-10-23 11:02:29 +00:00
|
|
|
$to_hash = $this->_customer_id . '|' . $this->_session_expiration;
|
2014-05-08 09:36:19 +00:00
|
|
|
$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;
|
2013-10-17 14:29:39 +00:00
|
|
|
|
2019-02-05 13:02:20 +00:00
|
|
|
if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
|
2019-03-14 17:14:57 +00:00
|
|
|
wc_setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
|
2019-02-05 13:02:20 +00:00
|
|
|
}
|
2015-10-07 13:58:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-14 17:14:57 +00:00
|
|
|
/**
|
|
|
|
* Should the session cookie be secure?
|
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
protected function use_secure_cookie() {
|
|
|
|
return apply_filters( 'wc_session_use_secure_cookie', wc_site_is_https() && is_ssl() );
|
|
|
|
}
|
|
|
|
|
2015-10-07 13:58:13 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Return true if the current user has an active session, i.e. a cookie to retrieve values.
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function has_session() {
|
2017-12-15 14:34:04 +00:00
|
|
|
return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
|
2015-10-07 13:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set session expiration.
|
|
|
|
*/
|
|
|
|
public function set_session_expiration() {
|
2015-11-03 13:31:20 +00:00
|
|
|
$this->_session_expiring = time() + intval( apply_filters( 'wc_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
|
|
|
|
$this->_session_expiration = time() + intval( apply_filters( 'wc_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
|
2015-10-07 13:58:13 +00:00
|
|
|
}
|
2013-01-15 19:51:19 +00:00
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Generate a unique customer ID for guests, or return user ID if logged in.
|
2014-09-20 18:59:26 +00:00
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID.
|
2013-01-15 19:51:19 +00:00
|
|
|
*
|
2018-01-23 13:36:53 +00:00
|
|
|
* @return string
|
2013-01-15 19:51:19 +00:00
|
|
|
*/
|
2013-09-13 12:39:46 +00:00
|
|
|
public function generate_customer_id() {
|
2018-01-23 13:36:53 +00:00
|
|
|
$customer_id = '';
|
|
|
|
|
2014-05-08 09:36:19 +00:00
|
|
|
if ( is_user_logged_in() ) {
|
2018-01-23 13:36:53 +00:00
|
|
|
$customer_id = get_current_user_id();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( empty( $customer_id ) ) {
|
2017-12-15 14:34:04 +00:00
|
|
|
require_once ABSPATH . 'wp-includes/class-phpass.php';
|
2018-01-23 13:36:53 +00:00
|
|
|
$hasher = new PasswordHash( 8, false );
|
|
|
|
$customer_id = md5( $hasher->get_random_bytes( 32 ) );
|
2014-05-08 09:36:19 +00:00
|
|
|
}
|
2018-01-23 13:36:53 +00:00
|
|
|
|
|
|
|
return $customer_id;
|
2013-01-15 19:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-01-23 13:36:53 +00:00
|
|
|
* Get the session cookie, if set. Otherwise return false.
|
|
|
|
*
|
|
|
|
* Session cookies without a customer ID are invalid.
|
2013-01-15 19:51:19 +00:00
|
|
|
*
|
2015-01-23 11:11:27 +00:00
|
|
|
* @return bool|array
|
2013-01-15 19:51:19 +00:00
|
|
|
*/
|
2013-09-13 12:39:46 +00:00
|
|
|
public function get_session_cookie() {
|
2017-12-15 14:34:04 +00:00
|
|
|
$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
|
|
|
|
|
|
|
|
if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
|
2013-01-15 19:51:19 +00:00
|
|
|
return false;
|
2014-05-08 09:36:19 +00:00
|
|
|
}
|
2013-01-15 19:51:19 +00:00
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
|
2013-01-15 19:51:19 +00:00
|
|
|
|
2018-01-23 13:36:53 +00:00
|
|
|
if ( empty( $customer_id ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
// Validate hash.
|
2015-10-23 11:02:29 +00:00
|
|
|
$to_hash = $customer_id . '|' . $session_expiration;
|
2013-01-15 19:51:19 +00:00
|
|
|
$hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
|
|
|
|
|
2016-01-18 10:34:06 +00:00
|
|
|
if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
|
2013-01-15 19:51:19 +00:00
|
|
|
return false;
|
2014-05-08 09:36:19 +00:00
|
|
|
}
|
2013-01-15 19:51:19 +00:00
|
|
|
|
2013-01-16 11:05:50 +00:00
|
|
|
return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
|
2013-01-15 19:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Get session data.
|
2013-01-15 19:51:19 +00:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2013-09-13 12:39:46 +00:00
|
|
|
public function get_session_data() {
|
2015-10-07 13:47:29 +00:00
|
|
|
return $this->has_session() ? (array) $this->get_session( $this->_customer_id, array() ) : array();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Gets a cache prefix. This is used in session names so the entire cache can be invalidated with 1 function call.
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
2015-10-07 13:47:29 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function get_cache_prefix() {
|
2015-11-13 23:12:44 +00:00
|
|
|
return WC_Cache_Helper::get_cache_prefix( WC_SESSION_CACHE_GROUP );
|
2013-01-15 19:51:19 +00:00
|
|
|
}
|
|
|
|
|
2015-10-07 13:58:13 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Save data.
|
2015-10-07 13:58:13 +00:00
|
|
|
*/
|
|
|
|
public function save_data() {
|
2017-12-15 14:34:04 +00:00
|
|
|
// Dirty if something changed - prevents saving nothing new.
|
2015-10-07 13:58:13 +00:00
|
|
|
if ( $this->_dirty && $this->has_session() ) {
|
2015-10-07 13:47:29 +00:00
|
|
|
global $wpdb;
|
|
|
|
|
2018-09-26 17:46:28 +00:00
|
|
|
$wpdb->query(
|
|
|
|
$wpdb->prepare(
|
|
|
|
"INSERT INTO {$wpdb->prefix}woocommerce_sessions (`session_key`, `session_value`, `session_expiry`) VALUES (%s, %s, %d)
|
|
|
|
ON DUPLICATE KEY UPDATE `session_value` = VALUES(`session_value`), `session_expiry` = VALUES(`session_expiry`)",
|
|
|
|
$this->_customer_id,
|
|
|
|
maybe_serialize( $this->_data ),
|
|
|
|
$this->_session_expiration
|
2016-02-23 12:48:48 +00:00
|
|
|
)
|
|
|
|
);
|
2013-01-16 11:05:50 +00:00
|
|
|
|
2015-10-07 13:47:29 +00:00
|
|
|
wp_cache_set( $this->get_cache_prefix() . $this->_customer_id, $this->_data, WC_SESSION_CACHE_GROUP, $this->_session_expiration - time() );
|
2015-10-07 13:58:13 +00:00
|
|
|
$this->_dirty = false;
|
|
|
|
}
|
|
|
|
}
|
2013-01-16 09:53:08 +00:00
|
|
|
|
2015-10-07 13:58:13 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Destroy all session data.
|
2015-10-07 13:58:13 +00:00
|
|
|
*/
|
|
|
|
public function destroy_session() {
|
2015-10-07 13:47:29 +00:00
|
|
|
$this->delete_session( $this->_customer_id );
|
2018-11-20 17:58:14 +00:00
|
|
|
$this->forget_session();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forget all session data without destroying it.
|
|
|
|
*/
|
|
|
|
public function forget_session() {
|
2019-03-14 17:14:57 +00:00
|
|
|
wc_setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
|
2014-05-20 09:01:26 +00:00
|
|
|
|
|
|
|
wc_empty_cart();
|
2014-09-20 18:59:26 +00:00
|
|
|
|
2014-05-20 09:01:26 +00:00
|
|
|
$this->_data = array();
|
|
|
|
$this->_dirty = false;
|
|
|
|
$this->_customer_id = $this->generate_customer_id();
|
|
|
|
}
|
|
|
|
|
2015-05-21 23:23:33 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
2017-12-15 14:34:04 +00:00
|
|
|
* @param int $uid User ID.
|
2015-05-21 23:23:33 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function nonce_user_logged_out( $uid ) {
|
|
|
|
return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
|
|
|
|
}
|
|
|
|
|
2015-10-07 13:58:13 +00:00
|
|
|
/**
|
2017-12-15 14:46:02 +00:00
|
|
|
* Cleanup session data from the database and clear caches.
|
2013-01-16 09:53:08 +00:00
|
|
|
*/
|
|
|
|
public function cleanup_sessions() {
|
|
|
|
global $wpdb;
|
|
|
|
|
2017-12-15 14:46:02 +00:00
|
|
|
$wpdb->query( $wpdb->prepare( "DELETE FROM $this->_table WHERE session_expiry < %d", time() ) ); // @codingStandardsIgnoreLine.
|
2014-01-13 10:45:31 +00:00
|
|
|
|
2017-12-15 14:46:02 +00:00
|
|
|
if ( class_exists( 'WC_Cache_Helper' ) ) {
|
2015-11-13 23:12:44 +00:00
|
|
|
WC_Cache_Helper::incr_cache_prefix( WC_SESSION_CACHE_GROUP );
|
2015-10-07 13:47:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Returns the session.
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
2017-12-15 14:34:04 +00:00
|
|
|
* @param string $customer_id Custo ID.
|
|
|
|
* @param mixed $default Default session value.
|
2015-10-07 13:47:29 +00:00
|
|
|
* @return string|array
|
|
|
|
*/
|
2015-10-07 13:58:13 +00:00
|
|
|
public function get_session( $customer_id, $default = false ) {
|
2015-10-07 13:47:29 +00:00
|
|
|
global $wpdb;
|
|
|
|
|
|
|
|
if ( defined( 'WP_SETUP_CONFIG' ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-15 14:34:04 +00:00
|
|
|
// Try to get it from the cache, it will return false if not present or if object cache not in use.
|
2015-10-07 13:47:29 +00:00
|
|
|
$value = wp_cache_get( $this->get_cache_prefix() . $customer_id, WC_SESSION_CACHE_GROUP );
|
|
|
|
|
|
|
|
if ( false === $value ) {
|
2017-12-15 14:46:02 +00:00
|
|
|
$value = $wpdb->get_var( $wpdb->prepare( "SELECT session_value FROM $this->_table WHERE session_key = %s", $customer_id ) ); // @codingStandardsIgnoreLine.
|
2015-10-07 13:47:29 +00:00
|
|
|
|
|
|
|
if ( is_null( $value ) ) {
|
|
|
|
$value = $default;
|
2014-01-13 10:45:31 +00:00
|
|
|
}
|
2015-10-07 13:47:29 +00:00
|
|
|
|
2019-06-03 21:11:46 +00:00
|
|
|
$cache_duration = $this->_session_expiration - time();
|
2019-06-18 20:20:39 +00:00
|
|
|
if ( 0 < $cache_duration ) {
|
2019-06-03 21:11:46 +00:00
|
|
|
wp_cache_add( $this->get_cache_prefix() . $customer_id, $value, WC_SESSION_CACHE_GROUP, $cache_duration );
|
|
|
|
}
|
2014-01-13 10:45:31 +00:00
|
|
|
}
|
2015-10-07 13:47:29 +00:00
|
|
|
|
|
|
|
return maybe_unserialize( $value );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Delete the session from the cache and database.
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
2017-12-15 14:34:04 +00:00
|
|
|
* @param int $customer_id Customer ID.
|
2015-10-07 13:47:29 +00:00
|
|
|
*/
|
2015-10-07 13:58:13 +00:00
|
|
|
public function delete_session( $customer_id ) {
|
2015-10-07 13:47:29 +00:00
|
|
|
global $wpdb;
|
|
|
|
|
|
|
|
wp_cache_delete( $this->get_cache_prefix() . $customer_id, WC_SESSION_CACHE_GROUP );
|
|
|
|
|
2018-07-31 19:10:51 +00:00
|
|
|
$wpdb->delete(
|
2015-10-07 13:47:29 +00:00
|
|
|
$this->_table,
|
|
|
|
array(
|
2016-08-27 01:46:45 +00:00
|
|
|
'session_key' => $customer_id,
|
2015-10-07 13:47:29 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Update the session expiry timestamp.
|
2015-10-07 13:58:13 +00:00
|
|
|
*
|
2017-12-15 14:34:04 +00:00
|
|
|
* @param string $customer_id Customer ID.
|
|
|
|
* @param int $timestamp Timestamp to expire the cookie.
|
2015-10-07 13:47:29 +00:00
|
|
|
*/
|
|
|
|
public function update_session_timestamp( $customer_id, $timestamp ) {
|
|
|
|
global $wpdb;
|
2015-10-07 13:58:13 +00:00
|
|
|
|
2015-10-07 13:47:29 +00:00
|
|
|
$wpdb->update(
|
|
|
|
$this->_table,
|
|
|
|
array(
|
2016-08-27 01:46:45 +00:00
|
|
|
'session_expiry' => $timestamp,
|
2015-10-07 13:47:29 +00:00
|
|
|
),
|
|
|
|
array(
|
2016-08-27 01:46:45 +00:00
|
|
|
'session_key' => $customer_id,
|
2015-10-07 13:47:29 +00:00
|
|
|
),
|
|
|
|
array(
|
2018-07-31 19:10:51 +00:00
|
|
|
'%d',
|
2015-10-07 13:47:29 +00:00
|
|
|
)
|
|
|
|
);
|
2013-01-16 09:53:08 +00:00
|
|
|
}
|
2014-09-20 18:59:26 +00:00
|
|
|
}
|