Filter hook 'attach_session_information'

in WP Core File wp-includes/class-wp-session-tokens.php at line 129

View Source

attach_session_information

Filter Hook
Description
Filters the information attached to the newly created session. Can be used to attach further information to a session.

Hook Information

File Location wp-includes/class-wp-session-tokens.php View on GitHub
Hook Type Filter
Line Number 129

Hook Parameters

Type Name Description
array $session Array of extra data.
int $user_id User ID.

Usage Examples

Basic Usage
<?php
// Hook into attach_session_information
add_filter('attach_session_information', 'my_custom_filter', 10, 2);

function my_custom_filter($session, $user_id) {
    // Your custom filtering logic here
    return $session;
}

Source Code Context

wp-includes/class-wp-session-tokens.php:129 - How this hook is used in WordPress core
<?php
 124  		 * @since 4.0.0
 125  		 *
 126  		 * @param array $session Array of extra data.
 127  		 * @param int   $user_id User ID.
 128  		 */
 129  		$session               = apply_filters( 'attach_session_information', array(), $this->user_id );
 130  		$session['expiration'] = $expiration;
 131  
 132  		// IP address.
 133  		if ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
 134  			$session['ip'] = $_SERVER['REMOTE_ADDR'];

PHP Documentation

<?php
/**
		 * Filters the information attached to the newly created session.
		 *
		 * Can be used to attach further information to a session.
		 *
		 * @since 4.0.0
		 *
		 * @param array $session Array of extra data.
		 * @param int   $user_id User ID.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/class-wp-session-tokens.php
Related Hooks

Related hooks will be displayed here in future updates.