progs/ap2.js
changeset 531 35ffb7a7eafa
parent 174 e2180cead443
equal deleted inserted replaced
530:6e08ee0d399d 531:35ffb7a7eafa
     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 {