title: Handle JWT Verify Failure
body: <p>I want to be able to change the JWT secret key and not cause a browser error for logged in users.</p>
  
  <p>Currently, if a user is logged in and the JWT secret key is changed, their browser throws an error. This can only be fixed by the user manually deleting the cookies from their browser.</p>
  
  <pre><code>server.express.use((req, res, next) =&gt; {
    const { token } = req.cookies;
    if (token) {
      const { userId } = jwt.verify(token, process.env.APP_SECRET);
      req.userId = userId;
    }
    next();
  });
  </code></pre>
  
  <p>What can I add to the above code so that if the jwt.verify fails, the user is forced to login again which would set a new cookie based on the new jwt secret key?</p>