feat: add http_cookie to WebsocketSession and UserSession #1653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a partial solution to this issue. #1213
Adding access to
http_cookie
toWebSocketSession
andUserSession
facilitates the use of chainlit in enterprise applications that deploy multiple services under the same domain.Pull Request Summary
This pull request introduces support for handling HTTP cookies in the
backend/chainlit
module. The changes primarily involve adding a newhttp_cookie
parameter to various methods and ensuring that this parameter is properly propagated throughout the session handling and testing code.Session handling updates:
backend/chainlit/session.py
: Addedhttp_cookie
parameter to the__init__
method of several classes to handle HTTP cookies. [1] [2] [3] [4] [5] [6]backend/chainlit/socket.py
: Addedhttp_cookie
extraction from the environment and passed it to the session initialization. [1] [2]backend/chainlit/user_session.py
: Updatedget
method to includehttp_cookie
in the user session dictionary.Testing updates:
backend/tests/conftest.py
: Updatedcreate_mock_session
to include thehttp_cookie
parameter.backend/tests/test_user_session.py
: Added assertion to checkhttp_cookie
in thetest_user_session_set_get
test case.