Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi I want create Persistent sessions in Next Auth.
I want when the user check remember me the session (maxAge) is set for 7 day.
but when the remember me not checked the session is expired after the browser is close.
how can dynamically manage this.
my project is next js 16/type script.
i write this code base on some solution in internet in session callback but is not working:

            if (!token.rememberMe) {
                session.expires = new Date(0).toISOString();
                session.maxAge = 0;

            } else {
                const expires = new Date(Date.now() + SEVEN_DAYS * 1000);
                session.expires = expires.toISOString();
                session.maxAge = Number(expires);
            }

how can fix this? please help

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Help
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.