MCPcopy
hub / github.com/django/django / get_signed_cookie

Method get_signed_cookie

django/http/request.py:239–261  ·  view source on GitHub ↗

Attempt to return a signed cookie. If the signature fails or the cookie has expired, raise an exception, unless the `default` argument is provided, in which case return that value.

(self, key, default=RAISE_ERROR, salt="", max_age=None)

Source from the content-addressed store, hash-verified

237 )
238
239 def get_signed_cookie(self, key, default=RAISE_ERROR, salt="", max_age=None):
240 """
241 Attempt to return a signed cookie. If the signature fails or the
242 cookie has expired, raise an exception, unless the `default` argument
243 is provided, in which case return that value.
244 """
245 try:
246 cookie_value = self.COOKIES[key]
247 except KeyError:
248 if default is not RAISE_ERROR:
249 return default
250 else:
251 raise
252 try:
253 value = signing.get_cookie_signer(salt=key + salt).unsign(
254 cookie_value, max_age=max_age
255 )
256 except signing.BadSignature:
257 if default is not RAISE_ERROR:
258 return default
259 else:
260 raise
261 return value
262
263 def build_absolute_uri(self, location=None):
264 """

Calls 1

unsignMethod · 0.45