Don't Keep Full IP Addresses in Login Sessions
Shortens the IP address and drops the browser details WordPress stores with every login session, so session records no longer hold full personal data.
Opens WPIDE on
Code
add_filter( 'attach_session_information', function ( $session ) {
if ( ! empty( $session['ip'] ) ) {
$session['ip'] = wp_privacy_anonymize_ip( $session['ip'] );
}
unset( $session['ua'] );
return $session;
}, 20 );
Notes
Security snippets that compare session IPs will compare the shortened address instead.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.