Hello, i want to print on my website how many people are viewing it. I thought doing it with cookies:
1. Give the guest a guest cookie. Increase a static variable "guest".
2. If he registers, give him a user cookie. Decrease "guest" by 1 , Increase "user" by 1. (_Problem_: how to delete his guest cookie? It's MaxAge is -1 )
3.If user/guest exits delete the corresponding cookie and decrease "guest" / "user" variable.

I found out that the api doesn't give such options as deleting a cookie, or notifying that it expired/quit. So how could it be done? Is there some trick i need to know or maybe i should try a new method doing that?

Recommended Answers

All 6 Replies

Alex_,
What happned when user-agent is cookies-disabled. Think about Session & Database.

Alex_,
What happned when user-agent is cookies-disabled. Think about Session & Database.

Please tell me something about sessions so i can know what to look for. Or give me a link to a tutorial,or smthing...
And what do you suggest me to do with the database? Is it storing the count in it instead of public static variables, or smthing else?

Thanks again.
I was wondering... is

request.setAttribute("x","");

the same as

HttpSession session = request.getSession(true);
session.setAttribute("x","");

?

No, they are not same. There is a difference in their scope.

Can you please make clear the difference for me?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.