Jump to content

Online Friends Script


never_rain

Recommended Posts

I have a website where users can add their friends. What I am trying to achieve is to show every user that who are their friends that are currently online. If any one knows a link to any script or tutorial that explains this, Please help.

 

Thanks,

 

Faisal

Link to comment
Share on other sites

I have a table for the users to store their username password, photo, and some profile detail. Once a user logs in, seperate session is created I believe I have to store that session in a table and once they logout, then I have to delete the session from the table. Does this make any sense ?

Link to comment
Share on other sites

well you wouldn't store a session in a table..

 

 

you just add:

 

session_start();

 

to the top of your php docs.. then when you want to log the user out just:

 

session_destroy();

 

 

 

if you want to show them as online you can just put a flag into their row of the DB.. flagging that they are online. remove the flag when they logout

Link to comment
Share on other sites

if you want to record a persons friends you could just one one field of a row called say "friendIDs" or something then just use some special symbol to concatenate them together like "5-3-4-6-7-?..." saving you some space. When you need to use the ID's to pull friend info from the database.. just pull this long string out and break it apart using explode() method.. now you have all your id's in an array to use yay.

 

same thing for the online thing.. just mark the user as online with a flag in the DB under say "online" field w/e , then while your retrieving friend information you can also do a check for which of those friends is online. '

 

you don't wana get in the habit of making a bunch of different tables in a database for the same thing.. like a user.. just use one table for users giving them each their own row.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.