Jump to content

Change code to display session user


hoponhiggo

Recommended Posts

Hi guys

 

I have some code which displays the profile picture the logged in user.

 

<?php
$dir = "prof_pics";

$sql = "SELECT prof_pic FROM users WHERE username = '{$_SESSION['MM_Username']}'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0) die("Username not found in database.");

$row = mysql_fetch_array($res);
echo "<img src='$dir/{$row['prof_pic']}' width='88' height='88' align= center><br>";
?>

 

What i want to do is adapt this to show the profile picture of all the currently 'online' users.

 

Is there a session variable i could replcae the '{$_SESSION['MM_Username']}' with on the sql?

 

Link to comment
https://forums.phpfreaks.com/topic/240986-change-code-to-display-session-user/
Share on other sites

You would need to have some way of determining who was online... you could have an entry in the table users 'online' 1/0 where one is online and 0 is offline.

 

Set the field when logging In and out.  THen you just need a way of checking if the person is still online during their session encased they close the browser without pressing log out.

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.