Need Help With Cookie

I'm generating a token when the user logs in, & sending it to the browser, but the catch is cookie is present in the network tab (as a login response) But it is not getting added to the Application > Storage > Cookies So whenever I refresh, I keep getting logout as the cookie is not present in the req.cookies.COOKIE_NAME. I'm tired for 2-3 days, what is causing this problem ? 😭😭😭
No description
No description
No description
No description
31 Replies
ἔρως
ἔρως3mo ago
the cookie is only accessible over http you can see that because the H column had a checkmark
hgs
hgs3mo ago
U could put it in same origin or use proxy
ἔρως
ἔρως3mo ago
it probably won't work the cookie is http only javascript doesn't have access to it
hgs
hgs3mo ago
need some config with credentials
ἔρως
ἔρως3mo ago
that won't matter if the server sends the cookie set to http only
ἔρως
ἔρως3mo ago
if the H has a tick mark, javascript will never see it
No description
ἔρως
ἔρως3mo ago
also, the "expires" is set to "session", which means that the cookie will be lost when the browser closes i think it is gone too, if you close a tab
hgs
hgs3mo ago
Agree with session part But I think config the credentials will store cookie with HTTPonly option
ἔρως
ἔρως3mo ago
if that happens, that's a massive security issue
hgs
hgs3mo ago
I just checked my website😂
No description
ἔρως
ἔρως3mo ago
you shouldn't be able to read it from js but, it should be sent in all http requests for that domain
hgs
hgs3mo ago
I agree it
ἔρως
ἔρως3mo ago
and here:
[...] keep getting logout as the cookie is not present in the req.cookies.COOKIE_NAME.
he's trying to read the cookie from javascript which will never work which means, he relies on reading the cookie and passing it to something else to get the information
hgs
hgs3mo ago
I read it by middleware in server side
ἔρως
ἔρως3mo ago
with the http only flag, that's the only place where you can read it or manually, in the developer tools
hgs
hgs3mo ago
My site was ddos by cookie It's unsafe
ἔρως
ἔρως3mo ago
i can't see how that's possible, since cookies are supposed to be limited to 4kb unless it was a specially crafted request that goes above the 4kb and the server chokes
hgs
hgs3mo ago
bcs I didn't set limit for api calls, and someone used cookie with scripts to call apis for 3000 times in half a hour
ἔρως
ἔρως3mo ago
ah, it wasn't the cookie fault but the lack of rate limits
hgs
hgs3mo ago
emmm. thats more accurate
ἔρως
ἔρως3mo ago
but that is interesting nonetheless but, going back to the topic here op can't get the cookie in javascript because it's http only to read it, the code must run in the server, or the cookie must be sent without the http only flag
hgs
hgs3mo ago
if its nextjs. op could read it in middleware
ἔρως
ἔρως3mo ago
or send the token over in the server response as well
hgs
hgs3mo ago
u mean send token by api response?
ἔρως
ἔρως3mo ago
yes it doesn't fix the issue, but can be used as a crutch
hgs
hgs3mo ago
yep, I thought of this path before
ἔρως
ἔρως3mo ago
it's not good. but works in a pinch
hgs
hgs3mo ago
In nextjs, rewrite and middleware could solve it Its convenient
ἔρως
ἔρως3mo ago
we dont know the stack and he hasnt said anything in a long time
hgs
hgs3mo ago
let's wait...
ἔρως
ἔρως3mo ago
ive been waiting
Want results from more Discord servers?
Add your server