diff -r 5031e7778fdb -r 02026ee18378 progs/App2.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/App2.js Tue Sep 23 01:06:00 2014 +0100 @@ -0,0 +1,22 @@ +var express = require('express'); +var cookie = require('cookie-parser') +var crypto = require('crypto'); + +var app = express(); +app.use(cookie()); + +app.get('/', function(req, res){ + var counter = req.cookies.counter || 0; + res.cookie('counter', counter + 1); + if (counter >= 5) { + res.write('You are a valued customer ' + + 'visting the site ' + counter + ' times.'); + } else { + res.write('This is visit number '+ counter +'!'); + } + res.end(); +}); + +// starting the server +app.listen(8000); +console.log("Server running at http://127.0.0.1:8000/");