def reset(self): """ Reset the session. Creates a new token, wipes any existing data. This does NOT expire the previous session ID (if there was one). To do this, call expire() first. """ self.id = create_token() log.debug("Generating new session %s" % self.id) self.modified = True self.last_update = datetime.now() self.clear()
def rotate(self): """ Rotate the session. Expires the existing session ID then creates a new one, while retaining the existing data. New session is not saved until the end of the request. """ log.debug("Rotating session %s out" % self.id) # Expire current session self.expire() # Create new session ID self.session_id = create_token() self.modified = True self.expired = False