Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if user is logged in laravel 4

Hi I am implementing a chat/inbox feature on my website. When users are not logged in and receive a message from another user, the website will send an email to the recipient of the message. However when the user is logged in it won't.

My questions is how do I tell whether a user is logged in or not? For example, if a user is logged in and then closes the browser my backend wouldn't know anything.

Btw I'm building a Angularjs SPA with a restful API in Laravel 4.?

like image 576
user1424508 Avatar asked Nov 29 '22 15:11

user1424508


1 Answers

if you are using build-in Laravel Auth:

if(Auth::check())
{
   //do something
}

if you are using Sentry:

if(Sentry::check())
{
   //do something
}
like image 85
Anam Avatar answered Dec 04 '22 02:12

Anam