You are here

function session_limit_page in Session Limit 6.2

Same name and namespace in other branches
  1. 5 session_limit.module \session_limit_page()
  2. 6 session_limit.module \session_limit_page()
  3. 7.2 session_limit.module \session_limit_page()

Display/Delete sessions.

1 string reference to 'session_limit_page'
session_limit_menu in ./session_limit.module
Implementation of hook_menu().

File

./session_limit.module, line 386
Limits multiple sessions per user.

Code

function session_limit_page() {
  global $user;
  if (variable_get('session_limit_behaviour', SESSION_LIMIT_DO_NOTHING) == SESSION_LIMIT_DISALLOW_NEW) {
    session_destroy();
    $user = drupal_anonymous_user();
    return;
  }
  $result = db_query('SELECT * FROM {sessions} WHERE uid = %d', $user->uid);
  while ($obj = db_fetch_object($result)) {
    $message = $user->sid == $obj->sid ? t('Your current session.') : '';
    $sids[$obj->sid] = t('<strong>Host:</strong> %host (idle: %time) <b>@message</b>', array(
      '%host' => $obj->hostname,
      '@message' => $message,
      '%time' => format_interval(time() - $obj->timestamp),
    ));
  }
  $form['sid'] = array(
    '#type' => 'radios',
    '#title' => t('Select a session to disconnect.'),
    '#options' => $sids,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Disconnect session'),
  );
  return $form;
}