You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# A silly thing to get just the signed cookie value.%Plug.Conn{resp_cookies: %{"testcookie"=>%{value: signed_cookie}}}=Plug.Conn.put_resp_cookie(conn,"testcookie","something",sign: true)# Now pretend you "received" it and see the Connconn|>Plug.Conn.put_req_header("cookie","testcookie=#{signed_cookie};")|>Plug.Conn.fetch_cookies(signed: ["testcookie"])|>IO.inspect(label: "conn")
The only documentation on Plug.Conn.req_cookies I could find is this bit in the "Fetchable Fields" section:
req_cookies - the request cookies (without the response ones)
Is this behavior expected? I certainly didn't expect it. I was expecting req_cookies to simply be cookies but without the resp_cookies. If this is expected behavior, we should document it thoroughly.
The text was updated successfully, but these errors were encountered:
I recently found out that
Plug.Conn.fetch_cookies/2
populatesPlug.Conn.req_cookies
with the plain cookie values (as received by the client)plug/lib/plug/conn.ex
Line 1503 in e11e5c4
while
Plug.Conn.cookies
contains the encrypted/verified values (ifsigned: true
orencrypted: true
where specified)plug/lib/plug/conn.ex
Lines 1513 to 1529 in e11e5c4
Here is a short piece of code to show what I mean
The output (shortned) looks like this:
The only documentation on
Plug.Conn.req_cookies
I could find is this bit in the "Fetchable Fields" section:Is this behavior expected? I certainly didn't expect it. I was expecting
req_cookies
to simply becookies
but without theresp_cookies
. If this is expected behavior, we should document it thoroughly.The text was updated successfully, but these errors were encountered: