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?

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","");

?

This article has been dead for over six months. Start a new discussion instead.