Hi!
I tried to implement cookies to my JSON API. All was fine on OS X, but
when I copied the file to linux server, it just crashes. I started now
from the drawing board and came up with simple example of cookies - at
least I think this is just like in examples. And it works as expected
on OS X with node 0.6.14, but crashes on Linux where the version is
0.6.15.
Is there a bug that prevents usage of express sessions on linux, or am
I just doing something wrong?
Here is the code:
// testing cookies
"use strict";
var port = 8084;
var express = require('express');
var app = express.createServer();
//app.set('jsonp callback', true);
var maxAge_s = 60;
app.use(express.logger(':remote-addr :req[X-Forwarded-For] :method
:url HTTP/:http-version :status :res[content-length] - :response-time
ms'));
app.use(express.cookieParser());
//app.use(express.session({"secret": "shhhh", "cookie": { maxAge:
1000*maxAge_s }}));
app.use(express.session({ secret: "keyboard cat" }));
app.use(app.router);
app.get('/', function (req, res) {
console.log('cookie: ' + JSON.stringify(req.cookies["connect.sid"]));
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write("Hello!\n");
res.end();
});
app.listen(port);
console.log('Server running in port: ' + port);
Here is the error that I get on linux (while on OS X this works):
[nodeuser@LinuxServer CookieTest]$ node cookietest.js
Server running in port: 8084
Error: connect.cookieParser("secret") required for security when using sessions
at Object.session [as handle]
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/middleware/session.js:212:28)
at next
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/proto.js:191:15)
at Object.cookieParser [as handle]
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5)
at next
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/proto.js:191:15)
at Object.logger [as handle]
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/middleware/logger.js:157:5)
at next
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/proto.js:191:15)
at Object.expressInit [as handle]
(/home/nodeuser/dev/CookieTest/node_modules/express/lib/middleware.js:35:5)
at next
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/proto.js:191:15)
at Object.query [as handle]
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/middleware/query.js:44:5)
at next
(/home/nodeuser/dev/CookieTest/node_modules/express/node_modules/connect/lib/proto.js:191:15)
127.0.0.1 - GET / HTTP/1.1 500 1316 - 2 ms
This is different error to what I'm getting in the real app, curious,
but all ready there is something wrong with this simple example.
--
HG.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en