简体   繁体   中英

Check which user logged in in PHP

I am new in php and I an making an application on iPhone that has a username and password for each user, and users are able to register. I would like to know if there are a lot of users, how can I check which user is logged in ?

When the user logged in their information will be displayed.

I am currently using

if ($id == 1)
{
   //command
}
if ($id == 2)
{
   //command
}
else
   //command

Is there a possible way to check which user is logged in without having to do the if else statement?

Thanks,

I suggest you to keep last user action time in database. Then select users, which did last action, for example, in last 10 minutes and track them as online users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM