Is it safe to use both SignedCookieJar and CookieJar in a single handler? #2036
-
I'm writing a handler like the one below and it actually works as intended. Please note that pub async fn handler(
sjar: SignedCookieJar,
jar: CookieJar,
) -> Result<(SignedCookieJar, SignedCookieJar), MyAppError> {
...
let sjar = sjar.add(Cookie::new("ABC", ...));
let jar = jar.add(Cookie::new("XYZ", ...));
...
Ok((sjar, jar))
} |
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Jun 8, 2023
Replies: 1 comment 1 reply
-
Yes that is safe, even if they share the same key. Cookies work via the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
yuttie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes that is safe, even if they share the same key.
Cookies work via the
Set-Cookie
header which contains a key/value pair likeSet-Cookie: key1=value1;
. So if you setABC
in a signed jar that translates to a signed value in the header. If you then setXYZ
in a different header those don't conflict.