progs/ap2.js
changeset 534 62985f147c85
parent 531 35ffb7a7eafa
equal deleted inserted replaced
533:98ae49ffc262 534:62985f147c85
     3 
     3 
     4 var app = express();
     4 var app = express();
     5 app.use(cookie());
     5 app.use(cookie());
     6 
     6 
     7 app.get('/', function(req, res){
     7 app.get('/', function(req, res){
     8     var counter =  parseInt(req.cookies.counter) || 0;
     8     var counter =  parseInt(req.cookies.counter || "") || 0;
     9     res.cookie('counter', counter + 1);
     9     res.cookie('counter', counter + 1);
    10     if (counter >= 5) {
    10     if (counter >= 5) {
    11         res.write('You are a valued customer ' + 
    11         res.write('You are a valued customer ' + 
    12                   'visting the site ' + counter + ' times.');
    12                   'visting the site ' + counter + ' times.');
    13     } else {
    13     } else {