code: def register_request_handlers(self, app: Flask) -> None:
      @app.after_request
      def validate_session(response: Response) -> Response:
          user_id = get_user_id()
  
          reset_token = (
              not request.cookies.get(self._jwt_cookie_name)
              or "async_channel_id" not in session
              or "async_user_id" not in session
              or user_id != session["async_user_id"]
          )
  
          if reset_token:
              async_channel_id = str(uuid.uuid4())
              session["async_channel_id"] = async_channel_id
              session["async_user_id"] = user_id
  
              sub = str(user_id) if user_id else None
              token = jwt.encode(
                  {"channel": async_channel_id, "sub": sub},
                  self._jwt_secret,
                  algorithm="HS256",
              )
  
              response.set_cookie(
                  self._jwt_cookie_name,
                  value=token,
                  httponly=True,
                  secure=self._jwt_cookie_secure,
                  domain=self._jwt_cookie_domain,
                  samesite=self._jwt_cookie_samesite,
              )
  
          return response
  
imports: import json
  import logging
  import uuid
  from typing import Any, Literal, Optional
  import jwt
  import redis
  from flask import Flask, request, Request, Response, session
  from superset.utils.core import get_user_id
label_desc: Use image node_id 3 for calling the AsyncQueryManager obj's underlying member method code with example usage: obj.register_request_handlers(app) and returns: response