I've seen several posts related to this but none solved my problem.
I have this code in server.js
var express = require('express');
var app = express();
app.configure(function(){
app.set(express.cookieParser());
app.set(express.session({secret: "This is a secret"}));
});
app.get('/name/:name', function(req, res){
req.session.name = req.params.name;
res.send("<a href='/name'>GO</a>");
});
app.get('/name', function(req, res){
res.send(req.session.name);
});
app.listen(3000);
When I go to http://localhost:3000/user/someone
that's the output that I get
TypeError: Cannot set property 'name' of undefined at /Users/Me/Node/server.js:10:19 at callbacks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…