I wanna build a view counter functionality for my website just like here on stackoverflow view counter: View counter functionality in stackoverflow I know how to build that, each time a user hit the post url, increment its view times by one. But the problem is that a user can come and refresh the page as much as he wants. How to fix that? any suggestion? I will be really glad if you can tell me the algorithm or code of that.
Asked
Active
Viewed 1,909 times
4
-
Maybe this can help: http://stackoverflow.com/questions/18799808/how-do-i-count-unique-visitors-to-my-site – Marcus Vinícius Monteiro Feb 11 '17 at 14:36
1 Answers
-1
You can customize this code to your POST function << Good lock (:
var http = require('http');
var userCount = 0;
var server = http.createServer(function (req, res) {
userCount++;
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('Hello!\n');
res.write('We have had ' + userCount + ' visits!\n');
res.end();
});
server.listen(9090);
console.log('server Up and running... 9090');

Mohsen
- 11
- 7