wppaste
WordPress

WP_User_Meta_Session_Tokens

Since
4.0.0
Source
wp-includes/class-wp-user-meta-session-tokens.php:17
Meta-based user sessions token manager.

Compatibility

WordPress
since 4.0.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Methods · 8

Source code

class WP_User_Meta_Session_Tokens extends WP_Session_Tokens { 	/**	 * Retrieves all sessions of the user.	 *	 * @since 4.0.0	 *	 * @return array Sessions of the user.	 */	protected function get_sessions() {		$sessions = get_user_meta( $this->user_id, 'session_tokens', true ); 		if ( ! is_array( $sessions ) ) {			return array();		} 		$sessions = array_map( array( $this, 'prepare_session' ), $sessions );		return array_filter( $sessions, array( $this, 'is_still_valid' ) );	} 	/**	 * Converts an expiration to an array of session information.	 *	 * @param mixed $session Session or expiration.	 * @return array Session.	 */	protected function prepare_session( $session ) {		if ( is_int( $session ) ) {			return array( 'expiration' => $session );		} 		return $session;	} 	/**	 * Retrieves a session based on its verifier (token hash).	 *	 * @since 4.0.0	 *	 * @param string $verifier Verifier for the session to retrieve.	 * @return array|null The session, or null if it does not exist	 */	protected function get_session( $verifier ) {		$sessions = $this->get_sessions(); 		if ( isset( $sessions[ $verifier ] ) ) {			return $sessions[ $verifier ];		} 		return null;	} 	/**	 * Updates a session based on its verifier (token hash).	 *	 * @since 4.0.0	 *	 * @param string $verifier Verifier for the session to update.	 * @param array  $session  Optional. Session. Omitting this argument destroys the session.	 */	protected function update_session( $verifier, $session = null ) {		$sessions = $this->get_sessions(); 		if ( $session ) {			$sessions[ $verifier ] = $session;		} else {			unset( $sessions[ $verifier ] );		} 		$this->update_sessions( $sessions );	} 	/**	 * Updates the user's sessions in the usermeta table.	 *	 * @since 4.0.0	 *	 * @param array $sessions Sessions.	 */	protected function update_sessions( $sessions ) {

Changelog

Introduced in 4.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-wp-user-meta-session-tokens.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.