Hello, I have an application which shows users which are currently logged into the system. The web application is running on a server and everytime a client on another computer logs in, he/she appears on the active users list. Below is some of the code:
loggedusers.php
......
<table cellpadding="3">
<tr bgcolor="#CCCCCC">
<td><b>User</b></td>
<td><b>Date In</b></td>
<td><b>Time In</b></td>
</tr>
<?php
while( $row = mysql_fetch_array( $result ) ) {
if($row['userID'] == $_SESSION['loggedUserID']){
?>
<tr bgcolor="#CCCCFF">
<td><?php echo $row['user']; ?></td>
<td><?php echo $row['dateIn']; ?></td>
<td><?php echo $row['timeIn']; ?></td>
</tr>
<?php
}
else {
?>
<tr bgcolor="#CCCCFF">
<td><?php echo $row['user']; ?></td>
<td><?php echo $row['dateIn']; ?></td>
<td><?php echo $row['timeIn']; ?></td>
<td><a href="logoutuser.php?userid=<?php echo $row['userID'] ?>">Remove User</a></td>
</tr>
<?php }
}?>
.......
logoutuser.php
<?php
session_start();
require_once 'includes/config.php';
include "includes/functions.php";
if ( $_REQUEST_METHOD = 'GET' ) {
if ( (isset( $_GET['userid'] ) && !empty( $_GET['userid'] ) )) {
$userID = escape_value( $_GET['userid'] );
$sql = "DELETE FROM tblloggedusers WHERE userID = $userID";
$result = mysql_query( $sql ) or die( mysql_error() );
// Missing logic for destroying/unsetting client's session
header( 'Location: loggedusers.php' );
exit;
}
}
?>
Now the problem I'm having is that when I click the "remove user" link of the loggedusers.php page from the admin server computer, it only removes user from the list but it does not destroy the client's session. I have tried using session_id() function but having trouble getting actual id of session. My table contains user ids of all logged in clients.
How do I forcebly destroy a session on a remote client computer and log them out? Any help would be greatly appreciated.