如何在快递路由器中设置Cookie"Priority = High"? [英] How do I set a cookie `Priority=High` in express router?
问题描述
Chrome浏览器具有Cookie标志 Priority
(优先级),该优先级确定将首先删除哪些Cookie(优先级较低)..
Chrome has a Cookie flag Priority
which prioritises which Cookies will be deleted first (lower priority)..
例如
Set-Cookie:GAPS = 1:ZYBtVMzURzU2umKMxZThJ2lVPxy3Hg:SvHhlG2k1Vy5pnA0; Path =/; Expires = Wed,04-Nov-2015 20:44:37 GMT; Secure; HttpOnly; Priority = High
/p>
我想通过express设置此值,但无论如何我还是看不到(文档).
I'd like to set this value from express, but I can't see anyway I'd do that (docs).
有人可以指出我正确的方向吗?(我需要自己设置标题吗?)
Can someone point me in the right direction? (Do I need to set the header myself?)
参考文献:
推荐答案
因此,我最终只使用了快递内部使用的 cookie
库...
So, I ended up just using the cookie
library internally used by express...
const cookie = require('cookie')
// ... inside route ...
let setCookie = cookie.serialize('name', value, {
expires: new Date(9999, 11, 31),
path: '/',
httpOnly: true,
secure: true,
domain: yourCookieDomain
})
setCookie += '; Priority=High'
res.append('Set-Cookie', setCookie)
给......
set-cookie:name = value;Domain = foobar.com;路径=/;过期时间为周五,格林尼治标准时间9999年12月31日00:00:00;HttpOnly;安全的;优先级=高
这篇关于如何在快递路由器中设置Cookie"Priority = High"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!