changeset 166 | bba0504abcf0 |
child 174 | e2180cead443 |
165:6f84ad98cf49 | 166:bba0504abcf0 |
---|---|
1 var express = require('express'); |
|
2 var cookie = require('cookie-parser') |
|
3 |
|
4 var app = express(); |
|
5 app.use(cookie()); |
|
6 |
|
7 app.get('/', function(req, res){ |
|
8 var counter = req.cookies.counter || 0; |
|
9 res.cookie('counter', counter + 1); |
|
10 if (counter >= 5) { |
|
11 res.write('You are a valued customer ' + |
|
12 'visting the site ' + counter + ' times.'); |
|
13 } else { |
|
14 res.write('This is visit number '+ counter +'!'); |
|
15 } |
|
16 res.end(); |
|
17 }); |
|
18 |
|
19 app.listen(8000); |