def get_sessions_to_clear(user=None, keep_current=False, device=None):
 if (not user):
  user = frappe.session.user
 if (not device):
  device = (frappe.session.data.device or u'desktop')
 limit = 0
 if (user == frappe.session.user):
  simultaneous_sessions = (frappe.db.get_value(u'User', user, u'simultaneous_sessions') or 1)
  limit = (simultaneous_sessions - 1)
 condition = u''
 if keep_current:
  condition = u' and sid != "{0}"'.format(frappe.db.escape(frappe.session.sid))
 return frappe.db.sql_list(u'select sid from tabSessions\n DCTB  DCTB where user=%s and device=%s {condition}\n DCTB  DCTB order by lastupdate desc limit {limit}, 100'.format(condition=condition, limit=limit), (user, device))

def get_sessions_to_clear ( user = None , keep_current = False , device = None ) : if ( not user ) : user = frappe . session . user if ( not device ) : device = ( frappe . session . data . device or u'desktop' ) limit = 0 if ( user == frappe . session . user ) : simultaneous_sessions = ( frappe . db . get_value ( u'User' , user , u'simultaneous_sessions' ) or 1 ) limit = ( simultaneous_sessions - 1 ) condition = u'' if keep_current : condition = u' and sid != "{0}"' . format ( frappe . db . escape ( frappe . session . sid ) ) return frappe . db . sql_list ( u'select sid from tabSessions\n DCTB  DCTB where user=%s and device=%s {condition}\n DCTB  DCTB order by lastupdate desc limit {limit}, 100' . format ( condition = condition , limit = limit ) , ( user , device ) )
returns sessions of the current user .