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

gretschduojet's avatar

Laravel backend on PHP site how to show user is logged in

Hello,

I have an existing site that I built a backend for in Laravel. The existing site is just straight php and not written in Laravel. When a user logs into the Laravel backend I have a dropdown link where the user can go to their profile and logout. However, I'm not sure how to display that the user is logged in when they go to different parts of the site that aren't built in Laravel. I'm guessing I would need some type of global cookie, but I'm not sure what the best way to do this is. Thank you in advance for the help.

0 likes
4 replies
martinbean's avatar

@gretschduojet Laravel cookies are encrypted. You won’t be able to use them outside of Laravel without a lot of effort, involving pulling parts of Laravel’s core into your vanilla PHP application.

toniperic's avatar

@gretschduojet imagine we have a table that records user's last activity.

To display all users that are currently online (lets say they have been active in the last 5 mintues), select from that table where last_activity >= (current_time - 5 minutes)

Update last_activity in the table for each user on every page load.

There you have it.

Hope I could help.

gretschduojet's avatar

Thank you for all of your responses. I haven't had time to actually implement it, but I will give your suggestions a try. Thank you again.

Please or to participate in this conversation.