How to chat with the admin?

Hello… sorry, I’m not Russian, I can make grammatical mistakes.

Here’s the question: I created a website on localhost, an e-shop. I want to have an online chat with the admin. If the admin is online, a window will open (well, it’s not very important). I just need a principle, an algorithm, and where can I find it? In general, is it possible to implement this on localhost? Or is it better to do all this on hosting?

Thanks in advance, I’ll be waiting for help.

Answer 1, authority 100%

Do you have a table online? Or somewhere where the last connection of the administrator is tracked? If yes, then you can do this

$time = time()
$sql= mysql_query("select id,last from users where id=[id admina]") 
//    ,  where    
if(($time-$sql['last']) < 900){

About the query: where last is a column in the user table. Maybe you have it called differently or not at all. This is me, an example.