Skip to content

Commit

Permalink
Merge pull request #124 from kinde-oss/peter/fix/remove-cookies-on-lo…
Browse files Browse the repository at this point in the history
…gout

fix: remove cookies from root domain
  • Loading branch information
peterphanouvong authored Feb 9, 2024
2 parents cd3c65d + 8d2a332 commit 3215596
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/session/sessionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ export const pageRouterSessionManager = (req, res) => {
maxAge: -1
})
]);

// remove cookies from the root domain
res?.setHeader('Set-Cookie', [
cookie.serialize(itemKey, '', {
path: '/',
maxAge: -1
})
]);
},
destroySession: () => {
res?.setHeader('Set-Cookie', [
Expand All @@ -174,6 +182,24 @@ export const pageRouterSessionManager = (req, res) => {
})
)
]);

// remove cookies from the root domain
res?.setHeader('Set-Cookie', [
...[
'id_token_payload',
'id_token',
'access_token_payload',
'access_token',
'user',
'refresh_token',
'post_login_redirect_url'
].map((name) =>
cookie.serialize(name, '', {
path: '/',
maxAge: -1
})
)
]);
}
};
};

0 comments on commit 3215596

Please sign in to comment.