WC_Session_Handler::restore_session_data
Restore the session data from the database.
Method of the class: WC_Session_Handler{}
Hooks from the method
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->restore_session_data();
Changelog
| Since 10.0.0 | Introduced. |
WC_Session_Handler::restore_session_data() WC Session Handler::restore session data code WC 10.8.1
private function restore_session_data() {
$session_data = $this->get_session_data();
/**
* Filters the session data when restoring from storage during initialization.
*
* This filter allows you to:
* 1. Modify the session data before it's loaded, including adding or removing specific session data entries
* 2. Clear the entire session by returning an empty array
*
* Note: If the filtered data is empty, the session will be destroyed and the
* guest's session cookie will be removed. This can be useful for high-traffic
* sites that prioritize page caching over maintaining all session data.
*
* @since 9.9.0
*
* @param array $session_data The session data loaded from storage.
* @return array Modified session data to be used for initialization.
*/
$this->_data = (array) apply_filters( 'woocommerce_restored_session_data', $session_data );
}