human
Complete this python program:
def channel_and_http_session(func):
assistant
#Here is the Python code you requested.

    """Enables both the channel_session and http_session.
    Stores the http session key in the channel_session on websocket.connect messages.
    It will then hydrate the http_session from that same key on subsequent messages.
    """
    @http_session
    @channel_session
    @functools.wraps(func)
    def inner(message, *args, **kwargs):
        if ((message.http_session is not None) and (settings.SESSION_COOKIE_NAME not in message.channel_session)):
            message.channel_session[settings.SESSION_COOKIE_NAME] = message.http_session.session_key
        elif ((message.http_session is None) and (settings.SESSION_COOKIE_NAME in message.channel_session)):
            session_engine = import_module(settings.SESSION_ENGINE)
            session = session_engine.SessionStore(session_key=message.channel_session[settings.SESSION_COOKIE_NAME])
            message.http_session = session
        return func(message, *args, **kwargs)
    return inner