app.post(’/views/login.html’,function(req,res,next){ res.setHeader(‘Set-Cookie’, “username=123; path=/; max-age=0”); console.log(req.headers); }); 这样到底哪错了? 可是貌似cookie删不掉啊 输出的结果是: { host: ‘localhost:3000’, connection: ‘keep-alive’, ‘content-length’: ‘14’, accept: ‘text/plain, /; q=0.01’, origin: ‘http://localhost:3000’, ‘x-requested-with’: ‘XMLHttpRequest’, ‘user-agent’: ‘Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Ge cko) Chrome/35.0.1916.153 Safari/537.36’, ‘content-type’: ‘application/x-www-form-urlencoded; charset=UTF-8’, referer: ‘http://localhost:3000/’, ‘accept-encoding’: ‘gzip,deflate,sdch’, ‘accept-language’: ‘zh-CN,zh;q=0.8’, cookie: ‘username=123; pwd=123’ }
res.setHeader(‘Set-Cookie’, “username=123; path=/; max-age=0”); 这一行并不是替换作用,是增加作用。
让Cookie过期就算删除了 貌似不是max-age 用 expires
另外域和路径要一至,不然只是增加一个立即过期的新cookie