本文整理匯總了TypeScript中express.Response.clearCookie方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Response.clearCookie方法的具體用法?TypeScript Response.clearCookie怎麽用?TypeScript Response.clearCookie使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類express.Response
的用法示例。
在下文中一共展示了Response.clearCookie方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: logout
export function logout(req: Request, res: Response) {
res.clearCookie("SESSIONID");
res.clearCookie("XSRF-TOKEN");
res.status(200).json({message: 'Logout Successful'});
}
示例2: next
req.session.destroy(e => {
if (e) {
this.sendError(res, this.LOGS.MASTER_INTERNAL_ERROR, {e, fn: "performLogout", file: "user.controller.js"});
} else {
res.clearCookie(userConfig.UNICORN);
next();
}
});
示例3: tryGet
tryGet(token).then(session => {
if (isSome<ISessionRow>(session)) {
req.session = session.value;
} else {
res.clearCookie("session_token");
}
next();
});
示例4: async
router.post('/', async (req: Request, res: Response) => {
const baseUrl = req.app.locals.config.get('NOTIFIER_BASE_URL');
const [key, value] = req.cookies.token;
try {
await db.deleteToken(req.user, key, value);
res.clearCookie('token', { path: baseUrl });
return res.sendStatus(200);
} catch (e) {
return res.status(500).json(e);
}
});
示例5:
router.get('/logout', (request: Request, response: Response) => {
response.clearCookie('connect.sid');
response.redirect('/');
});