title: Remove Cookies and Sign out server-side in Next.js
body: <p>I need to check if there's a token and if the token expired in getInitialProps, and then if the token is expired clear the Cookies from the browser and sign out the user.</p>
  <p>Here's what I'm doing so far ...</p>
  <pre><code>const isTokenExpired = (token) =&gt; {
      const currentTime = new Date().getTime() / 1000;
      const decodedToken: MetadataObj = jwt_decode(token);
      if (decodedToken.exp &lt; currentTime) {
          return true;
      } else {
          return false;
      }
  };
  
  import nextCookie from &quot;next-cookies&quot;;
  import Cookies from &quot;js-cookie&quot;;
  
  MyApp.getInitialProps = async ({ctx}: any) =&gt; {
      const { WebsiteToken } = nextCookie(ctx);
      if (WebsiteToken ) {
          if (isTokenExpired(WebsiteToken )) {
              console.log(&quot;Token Expired&quot;);
              Cookies.remove(&quot;WebsiteToken &quot;);
          }    
      }
  
  }
  </code></pre>
  <p>The console log works, but the Cookie is not removed from the browser, I know that this is because it didn't hit the client-side, but how can I do that from the server?</p>