#setting cookies infinite redirect loop

1 messages · Page 1 of 1 (latest)

hot surge
#

i set a session cookie and redirect to the same place (/) after setting it, but the next time the loader hits its not there so the loop continues

#

we are using remix createCookieSessionStorage

hot surge
#

potenntially found the cause

_remix_session_v2 cookie is appears twice in the cookie header.

and decoding it with jwt.io shows its malformed

how is that possible

noble gorge
#

you shouln’t send a response header with the name "Cookie", instead the cookie name should be "Set-Cookie" which instructs the receiver (browser) to attempt to set that cookie

hot surge
#

it still happens after changing it to this

hot surge
#

what could be malforming the cookie

cobalt tide
#

Did you figure this out? I'm hitting the same issue

high fable
#

@hot surge what kind of object is the headers variable? If it's the standard one I believe you want to use .set rather than .push. So something like

headers.set("Set-Cookie", newSession)
hot surge
#

yeah i narrowed it down a bit, somewhere between the lambda and the browser the set cookie param is being handled wrongly. the bug could be in remix code

this is likely because the lambda output is not standard HTTP stuff and does some manipulating of cookies

i moved the code out of the root loader into the server code with a custom handler so i add the set cookie param after the loaders have been handled and the response gets sent to browser

cookies still get malformed but it somehow now at least duplicates the malformed cookie and doesn't wreck the original

im moving to cloudflare and will see if i still have the same issue there

hot surge
warm bridge
#

fk this seems painful