this can be done by database , i will show how database used in this functionality.
you can add one extra field flag by default 0 , now when user login just modify flag to 1 for particular user, from this column you can filter users which are currently login ( flag==1 ).