progs/ap2.js
changeset 174 e2180cead443
parent 166 bba0504abcf0
child 531 35ffb7a7eafa
equal deleted inserted replaced
173:9126c13a7d93 174:e2180cead443
     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 = 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 {