Jump to content

Log out and set online counter to 0


ShopMAster

Recommended Posts

Hey guys, this is probably very simple just need some help.

 

I have a membership site that I created and as one of the last things I wanted to do was to set when members are online or not.  So I know there was probably an easier method but what I did was add a online field to the member table.  When a sucessful login is made they go to a loggedin.php page and on that page I have the following code:

 

$query = "UPDATE mwcplayers SET online=1 WHERE id= '".$_SESSION['id']."'";

 

This works great the users online status is set to 1.

 

My problem is when they log out and getting that online status set to 0 again:

 

here is my logout page logout.php:

 

<?php
session_start();
session_unset();

    $mesaj = '';
    
    include 'index.php';
    exit(0);
?>

 

I have no clue as to where to put the sql statement to set their online status to 0.

 

Please help.

 

Thanks.

 

Shopmaster

Link to comment
https://forums.phpfreaks.com/topic/41323-log-out-and-set-online-counter-to-0/
Share on other sites

<?php
session_start();

$query = "UPDATE mwcplayers SET online=0 WHERE id= '".$_SESSION['id']."'";
mysql_query($query) or die ("cannot amend table" . mysql_error());

session_unset();

    $mesaj = '';
    
    include 'index.php';
    exit(0);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.