cookie#
- class starlite.datastructures.cookie.Cookie#
Bases:
object
Container class for defining a cookie using the ‘Set-Cookie’ header.
See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie for more details regarding this header.
- path: str = '/'#
Path fragment that must exist in the request url for the cookie to be valid.
Defaults to ‘/’.
- __init__(key: str, path: str = '/', value: Optional[str] = None, max_age: Optional[int] = None, expires: Optional[int] = None, domain: Optional[str] = None, secure: Optional[bool] = None, httponly: Optional[bool] = None, samesite: Literal['lax', 'strict', 'none'] = 'lax', description: Optional[str] = None, documentation_only: bool = False) → None#
- samesite: Literal['lax', 'strict', 'none'] = 'lax'#
Controls whether or not a cookie is sent with cross-site requests.
Defaults to ‘lax’.
- description: Optional[str] = None#
Description of the response cookie header for OpenAPI documentation.
- documentation_only: bool = False#
Defines the Cookie instance as for OpenAPI documentation purpose only.
- property simple_cookie: SimpleCookie#
Get a simple cookie object from the values.
- Returns:
A SimpleCookie instance.
- to_header(**kwargs: Any) → str#
Return a string representation suitable to be sent as HTTP headers.
- Parameters:
**kwargs – Any kwargs to pass to the simple cookie output method.