Express.js的仅限会话的Cookie [英] Session-only cookie for Express.js
本文介绍了Express.js的仅限会话的Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
http://www.javascriptkit.com/javatutors/cookie.shtml
仅限会话的Cookie在另一个
手中存储在
浏览器内存中的信息,可用于
浏览器会话的持续时间。
换句话说,存储在
中的数据可以从
存储空间中获取,直到浏览器
关闭。在此期间从$ page
移动到
数据。
Session-only cookies, on the other hand, stores information in the browser memory, and is available for the duration of the browser session. In other words, the data stored inside a session cookie is available from the time of storage until the browser is closed. Moving from page to page during this time does not erase the data.
使用 Express.js ?
推荐答案
以下是我想要的(排序)。当我关闭浏览器时,信息就会消失。
The following is what I wanted (sort of). When I close browser the information is gone.
var express = require('express');
var app = express.createServer();
var MemoryStore = require('connect/middleware/session/memory');
app.use(express.bodyDecoder());
app.use(express.cookieDecoder());
app.get('/remember', function(req, res) {
res.cookie('rememberme', 'yes', { expires: new Date() - 1, httpOnly: true });
});
app.get('/', function(req, res){
res.send('remember: ' + req.cookies.rememberme);
});
app.listen(4000, '127.0.0.1');
这篇关于Express.js的仅限会话的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文