php settimeout call php function
Posted: Mon Aug 23, 2004 6:44 am
hey,
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:
Now is there a way I could reset or call this block of code, I guess throwing it in a function and calling it from javascript via settimeout() would work, but I have no idea how, I tried a couple things, and it wasnt reseting the script, I knew because the name would not appear, until I manually refreshed the page.. I need a way to do this auto, real fast and only once.. any ideas?? 
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"]);
}