Here is a simple program:
var express = require('express'); var app = express.createServer(); var count = 0; app.get("/", function(req, res) { res.send(count.toString()); count++; }); app.listen(3000);
When I open it in two different browsers, the first displays 0 and the second displays 1 .
Why? These are different sessions, so I expect node.js to use different child processes for them. My understanding, with PHP, is that the exchange of variables must be implemented using databases.
Why does node.js do this without external storage? This is one process, but multiple threads?
How to declare a variable related to a specific session?
Lai Yu-Hsuan Jun 15 '11 at 13:00 2011-06-15 13:00
source share