Page 221 - Nodejs 교과서 개정2판
P. 221
req.cookies न req.signedCookies ёী ٜয णפ
DPPLJF QBSTFSо ఃܳ ࢤࢿೡ ٸ ॳח Ѫ ইתפ ఃܳ ࢤࢿ ઁѢೞӝ ਤ೧ࢲח res.cookie res.c
learCookie ݫࢲ٘ܳ ࢎਊ೧ঠ פ res.cookie(키, 값, 옵션) ഋधਵ۽ ࢎਊפ ২࣌ ীࢲ
ಝࠄ ః ২࣌җ زੌפ domain expires httpOnly maxAge path secure ١ णפ
res.cookie('name', 'zerocho', {
expires: new Date(Date.now() + 900000),
httpOnly: true,
secure: true,
});
res.clearCookie('name', 'zerocho', { httpOnly: true, secure: true });
ఃܳ ۰ݶ ః৬ ч ৻ী ২࣌ب ഛ ੌ೧ঠ ఃо ਕפ ױ expiresա maxAge ২࣌ ੌ
ೡ ਃо হणפ
২࣌ ীח signedۄח ২࣌ חؘ ܳ true۽ ࢸೞݶ ః ٍী ࢲݺ ࠢणפ ղ ࢲߡо ఃܳ ݅
ٜח Ѫਸ Ѩૐೡ ࣻ ਵ۽ ࠗ࠙ ҃ ࢲݺ ২࣌ਸ ெفח Ѫ જणפ ࢲݺਸ ਤೠ ࠺ ఃח coo
kieParser ٜਝযী ੋࣻ۽ ֍ process.env.COOKIE_SECRET ؾפ
FYQSFTT TFTTJPO
ࣁ࣌ ҙܻਊ ٜਝযੑפ ۽Ӓੋ ١ ਬ۽ ࣁ࣌ਸ ҳഅೞѢա ౠ ࢎਊܳ ਤೠ ؘఠܳ दਵ۽
೧ل ٸ ݒ ਬਊפ ࣁ࣌ ࢎਊ߹۽ req.session ё উী ਬؾפ
app.use(session({
resave: false,
saveUninitialized: false,
secret: process.env.COOKIE_SECRET,
cookie: {
httpOnly: true,
secure: false,
},
name: 'session-cookie',
}));
FYQSFTT TFTTJPO ߡ ীח ղࠗਵ۽ DPPLJF QBSTFSܳ ࢎਊೞҊ যࢲ DPPLJF QBSTFS ٜਝয
ࠁ ٍী ਤ೧ঠ ೮݅ ߡ റࠗఠח ࢎਊೞ ঋѱ غয ࣽࢲо ࢚ҙহযणפ Ӓېب അ য