Whos Online - Cookies?
Posted: Fri May 20, 2005 12:46 am
I need help creating a who's online script in php for my site. I have found a few who's online script but I can't/don't know how to incoporate it into my site.
Just like the who's online script on vbulletin and phpbb, when a user logs in. I want it to display the username online.
Here's the cookie setting for the users.
I've read the "whos online" post here and it is all about using sessions as the log in. In the script I'm trying to create a whos online for is using cookie.[quote][/quote]
Just like the who's online script on vbulletin and phpbb, when a user logs in. I want it to display the username online.
Here's the cookie setting for the users.
Code: Select all
// REMEMBER ME
if(isset($rememberme) AND $rememberme == "e;1"e;) {
setcookie("e;username"e;, "e;$user"e;, time()+60*999999, "e;/"e;);
setcookie("e;password"e;, "e;$pass"e;, time()+60*999999, "e;/"e;);
setcookie("e;u_id"e;, "e;$u_id"e;, time()+60*999999, "e;/"e;);
} else {
// DONT REMEMBER ME
setcookie("e;username"e;, "e;$user"e;, 0, "e;/"e;);
setcookie("e;password"e;, "e;$pass"e;, 0, "e;/"e;);
setcookie("e;u_id"e;, "e;$u_id"e;, 0, "e;/"e;);
}Code: Select all
<?
$is_logged_in = "no";
if(isset($_COOKIE['username']) & isset($_COOKIE['password']) & isset($_COOKIE['u_id'])) {
$u_id = u_decrypt($_COOKIE['u_id']);
$user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_users WHERE u_id='$u_id'"));
if(stripslashes($_COOKIE['username']) == u_encrypt($user_info[username]) & stripslashes($_COOKIE['password']) == $user_info[password]) {
$is_logged_in = "yes";
} else {
$is_logged_in = "no";
}
} else {
$is_logged_in = "no";
}
if($is_logged_in == "yes") {
echo "You are logged in as $user_info[username].<br />";
} else {
include("form.php");
}
?>