I want to add a simple whos online script to my main page, but I dont want to refresh my whole page each time someone new logs in.. so I set up a cookie that gets there name and throws it in a cookie named active.. and then it checks for that cookie and if it's there it echo's the cookies value, which is their user name, like so:
Code: Select all
//set cookie
setcookie("active", $_SESSION['username'], time()+3600);
echo "Members Online<div>";
if (isset($_COOKIE["active"])) {
echo "".$_COOKIE["active"]."<div>";
} else {
//kill cookie
unset($_COOKIE["active"]);
}