Cookies¶
VisitCookie¶
The VisitCookie object holds vital information about the cookie we wish to set, as well as providing some utility functions.
init()¶
The object is initialised with values for:
name: usuallyvscr_vidorvscr_siddepending on whether this is a visitor cookie or a session cookievalue: the visitor_id or session_idexpires: defaults toarrow.now()but is passed a datetime based on the type of cookie (two years for visitor cookies, thirty minutes for session cookies)path: defaults to/(usually home) but can be configured with the path denoting the page from which the cookie is setdomain: the domain from which the cookie is setmax_age: defaults to 1800 but can be configuredsecure: defaults to True and should always be set that way
set_on_response()¶
Takes the values set on init() and uses the set_cookie() function from Python's requests library to set the cookie on the browser when the response is set.
to_json()¶
Straightforwardly, this serialises the name, value, expires, domain and path values into a JSON format.
ThirdPartyVisitCookie¶
This class extends the VisitCookie class - the only difference is when setting the response the samesite parameter is set to None.