How to change the page state whether the session is active or not
Unanswered
Northern Shoveler posted this in #help-forum
Northern ShovelerOP
Hi everyone, I'm trying to understand how to make my navbar change whether the session is active or not.
I'm storing the session information in my DB and sending a cookie with the session id to the client. The navbar is a server component, so I can call cookies().get(), but the nav doesn't seem to change after I actually send the cookie. I think it is because cookies().get() doesn't trigger the re-rendering of the components once it detects the cookie.
So, I should use useState(), but then the navbar would have to be a client component, and cookies().get() won't work anymore. How can I solve this? (without NextAuth)
I don't want my navbar to access the session id in the client because the cookie is secure and httpOnly (So it actually can't access the cookie, I think). Do I miss something?
I'm storing the session information in my DB and sending a cookie with the session id to the client. The navbar is a server component, so I can call cookies().get(), but the nav doesn't seem to change after I actually send the cookie. I think it is because cookies().get() doesn't trigger the re-rendering of the components once it detects the cookie.
So, I should use useState(), but then the navbar would have to be a client component, and cookies().get() won't work anymore. How can I solve this? (without NextAuth)
I don't want my navbar to access the session id in the client because the cookie is secure and httpOnly (So it actually can't access the cookie, I think). Do I miss something?