WC_Session_Handler::init_session_cookie()
Setup cookie and customer ID.
Description Description
Source Source
File: includes/class-wc-session-handler.php
public function init_session_cookie() { $cookie = $this->get_session_cookie(); if ( $cookie ) { $this->_customer_id = $cookie[0]; $this->_session_expiration = $cookie[1]; $this->_session_expiring = $cookie[2]; $this->_has_cookie = true; $this->_data = $this->get_session_data(); // If the user logs in, update session. if ( is_user_logged_in() && strval( get_current_user_id() ) !== $this->_customer_id ) { $guest_session_id = $this->_customer_id; $this->_customer_id = strval( get_current_user_id() ); $this->_dirty = true; $this->save_data( $guest_session_id ); $this->set_customer_session_cookie( true ); } // Update session if its close to expiring. if ( time() > $this->_session_expiring ) { $this->set_session_expiration(); $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); } } else { $this->set_session_expiration(); $this->_customer_id = $this->generate_customer_id(); $this->_data = $this->get_session_data(); } }
Changelog Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |