What does delete_resp_cookie do?

The documentation for Plug.Conn.delete_resp_cookie/3 merely mentions that the function “deletes a response cookie” without further explanation. What does the function actually do?

Suppose I write delete_resp_cookies(conn, :dummy). The documentation seems to suggest that the item with key :dummy will be removed from the map conn.resp_cookies. However, looking at the implementation code, apparently what the function does is the opposite: it puts an item with key :dummy into conn.resp.cookies and set its max_age to zero (with respect to the beginning of 1970-01-01).

It seems that by calling delete_resp_cookies(conn, :dummy), the server will tell the browser to mark the cookie “dummy” as already expired, thus this looks more like a hint to the browser that the cookie shall be removed. Am I correct?


That’s correct. The server is only telling the browser what to do, but the browser is responsible for managing it’s cookies.