Page 1 of 1

COOKIES!

Posted: Wed Apr 20, 2005 11:20 pm
by s.dot
I have a PHP chat programmed, and it reads the value of a username stored in a cookie ( $_COOKIE['username'] :o ). Now my problem is, when they open another window, with the chat left open, and log out of my site in that window, they are left with a " " (blank) username in the chat.

So to solve this, I tried checking to see if the cookie isn't set, or if the cookie username == "" when they post a message, and attempt to redirect them to the login screen. Neither worked.

How could I solve this problem?

Posted: Wed Apr 20, 2005 11:40 pm
by McGruff
You should be able to check if a cookie is set and what the value is. Try print_r($_COOKIE) to debug.

You might also want to consider using different cookies for different purposes. If you have a separate cookie for the chat area, it won't be deleted when they logout somewhere else.

Sessions are also worth a look.