'start a new session'

def start(self):

    if (self.user == u'Guest'):
        sid = u'Guest'
    else:
        sid = frappe.generate_hash()
    self.data.user = self.user
    self.data.sid = sid
    self.data.data.user = self.user
    self.data.data.session_ip = frappe.local.request_ip
    if (self.user != u'Guest'):
        self.data.data.update({u'last_updated': frappe.utils.now(), u'session_expiry': get_expiry_period(self.device), u'full_name': self.full_name, u'user_type': self.user_type, u'device': self.device, u'session_country': (get_geo_ip_country(frappe.local.request_ip) if frappe.local.request_ip else None)})
    if (self.user != u'Guest'):
        self.insert_session_record()
        frappe.db.sql(u'UPDATE    tabUser    SET    last_login    =    %(now)s,    last_ip    =    %(ip)s,    last_active    =    %(now)s\n DCTB  DCTB  DCTB  DCTB where    name=%(name)s', {u'now': frappe.utils.now(), u'ip': frappe.local.request_ip, u'name': self.data[u'user']})
        frappe.db.commit()
