| Server IP : 162.215.171.210 / Your IP : 216.73.216.50 Web Server : Apache System : Linux 162-215-171-210.bluehost.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : swansondentalgro ( 1070) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/swansondentalgro/.trash/mu-plugins-old/wpengine-common/ |
Upload File : |
<?php
namespace wpe\plugin;
/**
* Enforce some sanity on expiration times in wp_sessions. This is motivated by
* a recent bug in the EDD plugin that caused sessions to be expiring in the
* year 2058, which is not going to be even close to the right answer. Instead,
* we're going to cap the session timeout at 30 days.
*/
class SessionSanity {
public function register_hooks() {
add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 999999 );
}
public function set_expiration_time( $expiration ) {
/**
* Filter the upper bound on "sane" expriration times. IMPORTANT: This is a relative time (i.e., number of
* seconds until expiration) and NOT an absolute time (unixtime of expiration). Keep it small. Sessions are
* not designed to last forever.
*
* @since 2.1.14
*
* @param number $max_expiration maximum number of seconds until the session expires.
*/
$max_expiration = apply_filters( 'wpe_max_session_expiration', 30 * DAY_IN_SECONDS );
if ( $expiration > $max_expiration ) {
error_log( "Invalid session timeout: $expiration. Maximum allowed value: {$max_expiration}" );
return $max_expiration;
}
return $expiration;
}
}