# inactive-logout/trunk/core/Users.php

Inactive Logout, version trunk. 42 lines.

- Page: https://pluginprobe.com/plugins/inactive-logout/trunk/code/core/Users.php
- Raw: https://pluginprobe.com/plugins/inactive-logout/trunk/raw/core/Users.php
- Modified: 2025-06-18T16:03:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/inactive-logout/trunk/code/core/Users.php#L10-L20`.

```php
<?php

namespace Codemanas\InactiveLogout;

class Users {

	/**
	 * Logout the actual session from here
	 *
	 * @since 3.0.0
	 * @author Deepen
	 */
	public function logoutSession() {
		check_ajax_referer( '_inaajax', 'security' );
		if ( is_user_logged_in() ) {
			$this->setToastMessage();
			wp_logout();
		}

		wp_send_json( array(
			'isLoggedIn' => is_user_logged_in()
		) );

		wp_die();
	}

	private function setToastMessage() {
		if ( ! empty( Helpers::getSettings( 'show_toast_notification' ) ) ) {
			setcookie( 'ina_redirection_logged_out', true, time() + 120, "/" );
		}
	}

	private static ?Users $_instance = null;

	public static function getInstance(): ?Users {
		if ( is_null( self::$_instance ) ) {
			self::$_instance = new self();
		}

		return self::$_instance;
	}
}
```
