Showing posts with label Logout. Show all posts
Showing posts with label Logout. Show all posts

Monday, February 26, 2024

How to increase Logout session With AJAX in WordPress

function login_session_expired() {
// we only care to add scripts and styles if the user is logged in.
if ( is_user_logged_in() ) {

// add javascript file
wp_register_script( 'wp_auth_check', '/wp-includes/js/wp-auth-check.js' , array('heartbeat'), false, 1);
wp_localize_script( 'wp_auth_check', 'authcheckL10n', array(
'beforeunload' => __('Your session has expired. You can log in again from this page or go to the login page.'),
'interval' => apply_filters( 'wp_auth_check_interval', 1 * MINUTE_IN_SECONDS ), // default interval is 3 minutes
) );
wp_enqueue_script ('wp_auth_check');
// add css file
wp_enqueue_style( 'wp_auth_check','/wp-includes/css/wp-auth-check.css', array( 'dashicons' ), NULL, 'all' );
// add the login html to the page
add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 );
}
}
add_action( 'wp_enqueue_scripts', 'login_session_expired' );
// make sure the stylesheet appears on the lightboxed login iframe
function login_session_expired_styles() {
wp_enqueue_style( 'wp_auth_check','/wp-includes/css/wp-auth-check.css', array( 'dashicons' ), NULL, 'all' );
}
add_action( 'login_enqueue_scripts', 'login_session_expired_styles' );

1 hour Free Service for WordPress website :)

      1 hour Free Service for WordPress website :)