diff --git a/src/WordPress/WPCrm.php b/src/WordPress/WPCrm.php index 4d86310..04a71ec 100644 --- a/src/WordPress/WPCrm.php +++ b/src/WordPress/WPCrm.php @@ -360,6 +360,17 @@ class WPCrm return self::$user = new WPCrmUser(); } + /** + * Remove active user + * to prevent WPCrm::check to return true + * + * @return void + */ + public static function unsetActiveUser() + { + self::$user = null; + } + // --- PRIVATE --- METHODS /** @@ -457,6 +468,16 @@ class WPCrm if (!session_id() && !self::$sessionDestroyed) { session_start(); } + if ( + isset($_SESSION[self::$sessionKey]) and + isset($_SESSION['lastActivity']) and + ($_SESSION['lastActivity'] + 120) < time() + ) { + self::$sessionDestroyed = true; + unset($_SESSION[self::$sessionKey]); + } else { + $_SESSION['lastActivity'] = time(); + } if (!self::$user and array_key_exists(self::$sessionKey, $_SESSION)) { /** * The user object