code: def generate_session_id(self):
          
          secret_key = self._config.secret_key
          while True:
              rand = os.urandom(16)
              now = time.time()
              session_id = sha1(utf8("%s%s%s%s" % (
                  rand, now, self.handler.request.remote_ip, secret_key)))
              session_id = session_id.hexdigest()
              if session_id not in self.store:
                  break
  
          return session_id
docs: Generate a random id for session