
from handlers.handlerbase import HandlerBase
from db import db_session, Session


class LogoutHandler(HandlerBase):
    def handle(self, packet_msg):
        # Remove session
        s = db_session()
        s.query(Session).filter_by(key=self.sock.sid).delete()
        s.commit()
        s.close()

        # Dump out log
        self.log.info("Logged out.")
        self.log.set_sid(None)

        # Deauthenticate & clear session ID
        self.sock.authenticated = False
        self.sock.sid = None


from handlers.handlerbase import HandlerBase
from db import db_session, Session


class LogoutHandler(HandlerBase):
    def handle(self, packet_msg):
        # Remove session
        s = db_session()
        s.query(Session).filter_by(key=self.sock.sid).delete()
        s.commit()
        s.close()

        # Dump out log
        self.log.info("Logged out.")
        self.log.set_sid(None)

        # Deauthenticate & clear session ID
        self.sock.authenticated = False
        self.sock.sid = None
        self.sock.uid = None
        self.sock.level = 0

Clear all session data from websocket obj
Clear all session data from websocket obj

  
  from handlers.handlerbase import HandlerBase
  from db import db_session, Session
  
  
  class LogoutHandler(HandlerBase):
      def handle(self, packet_msg):
          # Remove session
          s = db_session()
          s.query(Session).filter_by(key=self.sock.sid).delete()
          s.commit()
          s.close()
  
          # Dump out log
          self.log.info("Logged out.")
          self.log.set_sid(None)
  
          # Deauthenticate & clear session ID
          self.sock.authenticated = False
          self.sock.sid = None
+         self.sock.uid = None
+         self.sock.level = 0
  
Clear all session data from websocket obj
## Code Before:

from handlers.handlerbase import HandlerBase
from db import db_session, Session


class LogoutHandler(HandlerBase):
    def handle(self, packet_msg):
        # Remove session
        s = db_session()
        s.query(Session).filter_by(key=self.sock.sid).delete()
        s.commit()
        s.close()

        # Dump out log
        self.log.info("Logged out.")
        self.log.set_sid(None)

        # Deauthenticate & clear session ID
        self.sock.authenticated = False
        self.sock.sid = None

## Instruction:
Clear all session data from websocket obj
## Code After:

from handlers.handlerbase import HandlerBase
from db import db_session, Session


class LogoutHandler(HandlerBase):
    def handle(self, packet_msg):
        # Remove session
        s = db_session()
        s.query(Session).filter_by(key=self.sock.sid).delete()
        s.commit()
        s.close()

        # Dump out log
        self.log.info("Logged out.")
        self.log.set_sid(None)

        # Deauthenticate & clear session ID
        self.sock.authenticated = False
        self.sock.sid = None
        self.sock.uid = None
        self.sock.level = 0
