File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,24 @@ impl Response {
216216
217217 /// Removes the cookie. This instructs the `CookiesMiddleware` to send a cookie with empty value
218218 /// in the response.
219+ ///
220+ /// ## Warning
221+ /// Take care when calling this function with a cookie that was returned by
222+ /// [`Request::cookie`](Request::cookie). As per [section 5.3 step 11 of RFC 6265], a new
223+ /// cookie is only treated as the same as an old one if it has a matching name, domain and
224+ /// path.
225+ ///
226+ /// The domain and path are not sent to the server on subsequent HTTP requests, so if a cookie
227+ /// was originally set with a domain and/or path, calling this function on a cookie with the
228+ /// same name but with either a different, or no, domain and/or path will lead to us sending an
229+ /// empty cookie that the user agent will treat as unrelated to the original one, and will thus
230+ /// not remove the old one.
231+ ///
232+ /// To avoid this you can manually set the [domain](Cookie::set_domain) and
233+ /// [path](Cookie::set_path) as necessary after retrieving the cookie using
234+ /// [`Request::cookie`](Request::cookie).
235+ ///
236+ /// [section 5.3 step 11 of RFC 6265]: https://tools.ietf.org/html/rfc6265#section-5.3
219237 pub fn remove_cookie ( & mut self , cookie : Cookie < ' static > ) {
220238 self . cookie_events . push ( CookieEvent :: Removed ( cookie) ) ;
221239 }
You can’t perform that action at this time.
0 commit comments