. i need if session already logged in. so terminate/Drop the newer session same login name without prompting
Can anyone advise me how to do?

Comments

bmeso’s picture

Title: Drop the newer session » Need Drop the newer session
mikespainhower’s picture

I'm using the 6.x-2.2 version of this module and have put together a rough method for dropping the newer session by changing the following (around line 444 in session_limit.module:

// disable default module behavior
// redirect to session handler.
// drupal_goto('session/limit');

// instead of allowing the logged in user to boot the other logged in user,
// automatically log them out and display a message

watchdog('session_limit', 'Duplicate session closed for %name.', array('%name' => $user->name));

// setting a message to be displayed after logout is ugly
// see: http://drupal.org/node/754560#comment-3960328

// 1) Call session_get_cookie_params to get the current session's attributes
$p = session_get_cookie_params();
// 2) Call session_destroy to end the current session
session_destroy();
// 3) Call session_set_cookie_params based on the values returned by 1)
session_set_cookie_params($p['lifetime'], $p['path'], $p['domain'], $p['secure'], $p['httponly']);
// 4) Call session_start to start a new session
session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy_sid', 'sess_gc');
session_start();
// 5) Log the user out with $user = drupal_anonymous_user(session_id());
// instead of just $user = drupal_anonymous_user();
$user = drupal_anonymous_user(session_id());
// 6) drupal_set_message followed by drupal_goto will now work.

$message  =  "You're not currently allowed to login because someone else is currently ";
$message .= "logged into your account. Please try again later.";
drupal_set_message($message, 'error'); 
drupal_goto(); // redirect to the front page

Hope this helps.

bmeso’s picture

Thanks your help is work
but face if login user browser are close or any resone lost session without logout,
who will be not login again error show already login
how can recover login if session cookies save in browser

johnennew’s picture

Status: Active » Closed (won't fix)

Closing old issue. If this is still needed, please check latest development releases to see if it is already covered and reopen if not.