WC_Session_Handler::save_data
Save data and delete guest session.
Метод класса: WC_Session_Handler{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WC_Session_Handler = new WC_Session_Handler(); $WC_Session_Handler->save_data( $old_session_key );
- $old_session_key(строка|разное)
- Optional session ID prior to user log-in. If
$old_session_keyis not tied to a user, the session will be deleted with the assumption that it was migrated to the current session being saved.
По умолчанию:''
Код WC_Session_Handler::save_data() WC Session Handler::save data WC 10.6.2
public function save_data( $old_session_key = '' ) {
// Dirty if something changed - prevents saving nothing new.
if ( $this->_dirty && $this->has_session() ) {
global $wpdb;
$wpdb->query(
$wpdb->prepare(
'INSERT INTO %i (`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->_table,
$this->get_customer_id(),
maybe_serialize( $this->_data ),
$this->_session_expiration
)
);
wp_cache_set( $this->get_cache_prefix() . $this->get_customer_id(), $this->_data, WC_SESSION_CACHE_GROUP, $this->_session_expiration - time() );
$this->_dirty = false;
/**
* Ideally, the removal of guest session data migrated to a logged-in user would occur within
* self::init_session_cookie() upon user login detection initially occurs. However, since some third-party
* extensions override this method, relocating this logic could break backward compatibility.
*/
if ( ! empty( $old_session_key ) && $this->get_customer_id() !== $old_session_key && ! is_object( get_user_by( 'id', $old_session_key ) ) ) {
$this->delete_session( $old_session_key );
}
}
}