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
ἔρως
ἔρως4mo ago
the cookie is only accessible over http you can see that because the H column had a checkmark
hgs
hgs4mo ago
U could put it in same origin or use proxy
ἔρως
ἔρως4mo ago
it probably won't work the cookie is http only javascript doesn't have access to it
hgs
hgs4mo ago
need some config with credentials
ἔρως
ἔρως4mo ago
that won't matter if the server sends the cookie set to http only
ἔρως
ἔρως4mo ago
if the H has a tick mark, javascript will never see it
No description
ἔρως
ἔρως4mo 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
hgs4mo ago
Agree with session part But I think config the credentials will store cookie with HTTPonly option
ἔρως
ἔρως4mo ago
if that happens, that's a massive security issue
hgs
hgs4mo ago
I just checked my website😂
No description
ἔρως
ἔρως4mo ago
you shouldn't be able to read it from js but, it should be sent in all http requests for that domain
hgs
hgs4mo ago
I agree it
ἔρως
ἔρως4mo 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
hgs4mo ago
I read it by middleware in server side
ἔρως
ἔρως4mo ago
with the http only flag, that's the only place where you can read it or manually, in the developer tools
hgs
hgs4mo ago
My site was ddos by cookie It's unsafe
ἔρως
ἔρως4mo 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
hgs4mo 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
ἔρως
ἔρως4mo ago
ah, it wasn't the cookie fault but the lack of rate limits
hgs
hgs4mo ago
emmm. thats more accurate
ἔρως
ἔρως4mo 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
hgs4mo ago
if its nextjs. op could read it in middleware
ἔρως
ἔρως4mo ago
or send the token over in the server response as well
hgs
hgs4mo ago
u mean send token by api response?
ἔρως
ἔρως4mo ago
yes it doesn't fix the issue, but can be used as a crutch
hgs
hgs4mo ago
yep, I thought of this path before
ἔρως
ἔρως4mo ago
it's not good. but works in a pinch
hgs
hgs4mo ago
In nextjs, rewrite and middleware could solve it Its convenient
ἔρως
ἔρως4mo ago
we dont know the stack and he hasnt said anything in a long time
hgs
hgs4mo ago
let's wait...
ἔρως
ἔρως4mo ago
ive been waiting
Want results from more Discord servers?
Add your server