search

Home  >  Q&A  >  body text

node.js - nodejs how to delete client cookies

nodejsHow to delete client cookies.
I made two interfaces.
A cookie will be set on the page after accessing interface a.
The cookie will be deleted after the b interface is accessed.
But my b interface cannot be deleted

res.setHeader("Set-Cookie", ["id="]);

I can clear it using this method, but the client will still leave fields like id=. Is there any way to delete it directly?

漂亮男人漂亮男人2732 days ago794

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-06-05 11:15:11

    function delete_cookie( name ) {
      document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
    }

    reply
    0
  • 怪我咯

    怪我咯2017-06-05 11:15:11

    You can only make it invalid immediately by setting the expiration time
    res.cookie(prop, '', {expires: new Date(0)});

    reply
    0
  • Cancelreply