Skip to content

How to destroy session with SID #80

Answered by kleydon
otobot1 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @otobot1,

Here's the way I'm deleting a user session (as well as all other sessions the user has, i.e. for logging out):

  return new Promise<BooleanPayload>( async (resolve, reject) => {

    ilog('Stored session exists for request session id; destroying it.')
    //Approach: https://stackoverflow.com/a/22519785
    return reqSession.destroy( async (err: Error) => {

      if (err) {
        return reject(Error('Logout failed: ' + err.message))
      }

      // If user has OTHER sessions with the same userId, destroy these as well
      const { count } = await prisma.session.deleteMany({
        // If prisma-session-store changes the format for data (unlikely)
        // the 'contain…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@otobot1
Comment options

Answer selected by otobot1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants