Get and Set a Single Cookie with Node.js HTTP Server

Posted by Corey Hart on Stack Overflow See other posts from Stack Overflow or by Corey Hart
Published on 2010-08-03T05:39:57Z Indexed on 2011/03/06 16:10 UTC
Read the original article Hit count: 259

Filed under:
|
|

I want to be able to set a single cookie, and read that single cookie with each request made to the nodejs server instance. Can it be done in a few lines of code, without the need to pull in a third party lib?

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

Just trying to take the above code directly from nodejs.org, and work a cookie into it.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about cookies