MCPcopy
hub / github.com/django/django / _update_cookie

Method _update_cookie

django/contrib/messages/storage/cookie.py:109–128  ·  view source on GitHub ↗

Either set the cookie with the encoded data if there is any data to store, or delete the cookie.

(self, encoded_data, response)

Source from the content-addressed store, hash-verified

107 return messages, all_retrieved
108
109 def _update_cookie(self, encoded_data, response):
110 """
111 Either set the cookie with the encoded data if there is any data to
112 store, or delete the cookie.
113 """
114 if encoded_data:
115 response.set_cookie(
116 self.cookie_name,
117 encoded_data,
118 domain=settings.SESSION_COOKIE_DOMAIN,
119 secure=settings.SESSION_COOKIE_SECURE or None,
120 httponly=settings.SESSION_COOKIE_HTTPONLY or None,
121 samesite=settings.SESSION_COOKIE_SAMESITE,
122 )
123 else:
124 response.delete_cookie(
125 self.cookie_name,
126 domain=settings.SESSION_COOKIE_DOMAIN,
127 samesite=settings.SESSION_COOKIE_SAMESITE,
128 )
129
130 def _store(self, messages, response, remove_oldest=True, *args, **kwargs):
131 """

Callers 1

_storeMethod · 0.95

Calls 2

delete_cookieMethod · 0.80
set_cookieMethod · 0.45

Tested by

no test coverage detected