progs/App2.js
changeset 172 aa7ddfee35c9
parent 163 02026ee18378
equal deleted inserted replaced
171:6cdf4d3906e2 172:aa7ddfee35c9
     4 
     4 
     5 var app = express();
     5 var app = express();
     6 app.use(cookie());
     6 app.use(cookie());
     7 
     7 
     8 app.get('/', function(req, res){
     8 app.get('/', function(req, res){
     9     var counter = req.cookies.counter || 0;
     9     var counter = parseInt(req.cookies.counter) || 0;
    10     res.cookie('counter', counter + 1);
    10     res.cookie('counter', counter + 1);
    11     if (counter >= 5) {
    11     if (counter >= 5) {
    12 	res.write('You are a valued customer ' + 
    12 	res.write('You are a valued customer ' + 
    13 		  'visting the site ' + counter + ' times.');
    13 		  'visting the site ' + counter + ' times.');
    14     } else {
    14     } else {