Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AbdulBazith's avatar

Find how many number of student logged in or not laravel

Guys iam working with a project its a online exam project for students

this is my example link

website.com/admin website.com/teacher website.com/student

all the three residing in same hosting but different laravel project accessing the same DB.

Now the teacher need to know how many student are in online

i referred in net and saw 2 ways

1) adding a column in user table "last_seen" and to fetch records   -> this access the db usually
2)create a middleware and store all active users on the Cache instead of the DB -> this easy apporach

which way is better? my db has more than 25000 students records. and it will be increased.

i think i cant use the second way as because my project are three different.. am i right?

and i have increased student session time


     'lifetime' => 35791394,

    'expire_on_close' => false,

most of the students use the application in mobile phone. so they wont logout, just they will come out from the browser. how i should handle this?

Kindly some one suggest any idea with any links

in this if i dont need the last seen time. then i think i dont need separate column. if i need last seen time then what shud i do?

my users table column are,

id,
email
username
user_type
password
userprfile_type
userprofile_id
created_at
updated_at
login_time
login_date
logout_time
logout_date

the last 4 columns what sense i kept is, when a student login, in the controller the logged in time and date will be filled and when student log out other 2 will be filled. but most of the student not logging out just closing the browser , so i cant make a condition to check whether he/she is online or not.

kindly some one suggest



0 likes
0 replies

Please or to participate in this conversation.