0

Is there any way to tell if a visitor to a site is new, or just the same one over and over again, for the purpose of a hit counter?

Sessions don't really seem to exist in MVC, so I know I can't really use them...

2 Answers 2

4

Is there any way to tell if a visitor to a site is new, or just the same one over and over again, for the purpose of a hit counter?

There's not a 100% reliable way due to the stateless nature of the web but for the purposes of a counter, setting a cookie and checking whether it's there or not is adequate for the most cases.

Sessions don't really seem to exist in MVC, so I know I can't really use them...

This is not true. You can use Session in ASP.NET MVC too. Although, in general, you should avoid server-side state as much as possible when you don't need it to ease scalability.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use sessions in ASP.NET MVC, but as Mehrdad points out, storing this kind of information on the server is not the way to go about it--use JavaScript cookies instead. And let your clients do the "heavy lifting".

Quircksmode has a great article on using JavaScript cookies.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.