home / docs / sections

sections: internals:internals-response-set-cookie

This data as json

id page ref title content breadcrumbs references
internals:internals-response-set-cookie internals internals-response-set-cookie Setting cookies with response.set_cookie() To set cookies on the response, use the response.set_cookie(...) method. The method signature looks like this: def set_cookie( self, key, value="", max_age=None, expires=None, path="/", domain=None, secure=False, httponly=False, samesite="lax", ): ... You can use this with datasette.sign() to set signed cookies. Here's how you would set the ds_actor cookie for use with Datasette authentication : response = Response.redirect("/") response.set_cookie( "ds_actor", datasette.sign({"a": {"id": "cleopaws"}}, "actor"), ) return response ["Internals for plugins", "Response class"] []
Powered by Datasette · Queries took 1.56ms