<?php 

function logout_cb() {
	$session = Session::getInstance();
	global $app;
	global $post_meta;

	$user = new user;
	$q = new query;

	$login_meta = (isset($app->user_meta['login_meta'])) ? unserialize($app->user_meta['login_meta']) : false;

	if($login_meta) {
		$login_meta = [
			'last_logout' => time(),
			'state' => 'offline',
			'last_login' => $login_meta['last_login']
		];

		$login_meta = serialize($login_meta);
		$user->update_user_meta($session->id, array('loggon_key' => 0, 'login_meta' => $login_meta));
	}
	$session->destroy();
	$q->delete('user_meta', ['user_id' => 0, 'meta_name' => 'loggon_key']);
	$q->delete('user_meta', ['user_id' => 0, 'meta_name' => 'login_meta']);
	?>
	<section>
      <div class="activation-page">
        <h2 class="headline text-yellow mb-4">Good bye</h2>

        <div class="activation-content">
          <h3><i class="fas fa-handshake text-success"></i> <?php echo apply_filters("logout_page_caption", "You have successfully signed out of your account!"); ?></h3>

          <p>
            <?php echo apply_filters("logout_page_message", "Do you want to sign in again? ") ?> <a href="<?php echo LOGIN_PAGE ?>">Go to Login Page</a>
          </p>
          <p>
          	Click <a href="<?php echo get_option('company_website') ?>">Here to visit the home page</a>
          </p>
        </div>
        <!-- /.error-content -->
      </div>
      <!-- /.error-page -->
    </section>
	<?php
	$content = ob_get_clean();
	setcookie("user_login", "", 1, "/");
	echo $content;
}