• Resolved Phil

    (@magicfilou)


    Hi!

    There is an option in your plugin to limit to one session BY USER (IP AND Browser) ?

    I need to limit each user to be logged in only once by ip or/and browser.

    If the user is already logged in on other browser and/or IP he receive a message like : You are already connected in other browser or with another IP. Please logout before start a new session ??

    ??? ??
    thanks in advance
    Best

Viewing 4 replies - 1 through 4 (of 4 total)
  • @magicfilou

    No, the free plugin does not include that option.

    iThemes Security Pro also does not include the option you described but it does include a module named User Security Check that will allow you to see sessions of who’s logged in — and be able to log them out instantly, everywhere. Not exactly what you are looking for but it does give you some session control.

    For more info about the User Security Check module read the article below:

    New WordPress User Security Check Helps You Review, Take Action on User Security

    Thread Starter Phil

    (@magicfilou)

    ok thank you for your quick answer but I really need to block the possibility for users to have several session open at the same time automaticaly.

    • This reply was modified 7 years, 3 months ago by Phil.

    @magicfilou

    Try and add this code to your active theme functions.php file:

    add_filter( 'authenticate', 'one_session_per_user', 30, 3 );
    
    function one_session_per_user( $user, $username, $password ) {
    	if ( is_wp_error( $user ) ) {
    		return $user;
    	}
    
    	$sessions = WP_Session_Tokens::get_instance( $user->ID );
    	$all_sessions = $sessions->get_all();
    	if ( count( $all_sessions ) ) {
    		$user = new WP_Error( 'already_signed_in', __( '<strong>ERROR</strong>: User already logged in.' ) );
    	}
    
    	return $user;
    }

    Tested, and seems to work but use it at your own risk.

    Thread Starter Phil

    (@magicfilou)

    Thank you ?? Seems to work yes ??

    little modification for WPML compatibility :

    add_filter( ‘authenticate’, ‘one_session_per_user’, 30, 3 );

    function one_session_per_user( $user, $username, $password ) {
    if ( is_wp_error( $user ) ) {
    return $user;
    }

    $sessions = WP_Session_Tokens::get_instance( $user->ID );
    $all_sessions = $sessions->get_all();
    if ( count( $all_sessions ) ) {
    $user = new WP_Error( ‘already_signed_in’, __( ‘ERROR: User already logged in.’,’login_limit’ ) );
    }

    return $user;
    }

    thanks again (y)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Single session’ is closed to new replies.