-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session doesn't seem to update until a whole server-side page reload happens #1667
Comments
The docs also says (right under what you quoted)
Didn't that help? So after you updated the session, just call |
hmmm, doesn't seem to have made a difference. - i've added |
but...explicitly doing something like this does seem to solve the problem:
why are these two behaviours different? i did assume that this code is broadly what |
Hmm. I think it should at least be: const [session, setSession] = useState(false)
useEffect(() => {
(async() => {
setSession(await getSession())
})()
}, []) I don't think The current implementation of I also haven't tried updating the session before, so I only quoted our documentation. Looking at the implementation of Lines 154 to 160 in dbe283f
My feeling was that when calling Could you verify that if you have two tabs (opened from the same window) open, and updating session from one of the tabs will update the session in the other tab when you call You should probably also |
Describe the bug
I'm using the
useSession
hook to grab some information about the logged in user, which I've customised using a callback:I have a "user profile" form which, when submitted, updates the currently logged in user in the database (specifically the
signature
column above, which stores a short string). i can verify that the changes have been made to the database right away.However, the session seems to still be returning the data before the change.
I need to make a full page reload from the server to bring it into sync with the database.
This is only a small change so I don't think there's a security risk, but what might happen if the things the user was allowed to access changed? Would the session not catch up until a full page reload?
Steps to reproduce
https://github.com/jhackett1/sms-message-tool
see:
Expected behavior
The
useSession
hook should always return correct, up to date information about the userFrom the docs:
Screenshots or error logs
console.log(session)
on the same page as the form returns the out-of-date data, so I can rule out my form being the source of the problem.I see no other errors or log messages that might help.
Additional context
Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
The text was updated successfully, but these errors were encountered: