Check if admin is already logged in and question about session

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Check if admin is already logged in and question about session

Post by lucadambros » 02 Aug 2019, 08:55

Hi,
I'm creating a global middleware and I need to know if an admin user is logged in or not.
I tried

Code: Select all

Auth::check()
but it always return false.

How do you store the session? How can I retrieve the data of the admin user and the session?

I'm using php 7.3, aimeos 2019.07.02 and laravel 5.8.

Thanks

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: Check if admin is already logged in and question about session

Post by aimeos » 02 Aug 2019, 14:43

Aimeos uses the Laravel "users" table so Auth::check() should work. Also, Aimeos uses the Laravel session so you can use it like in every other Laravel application.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lucadambros
Posts: 44
Joined: 24 Jun 2019, 14:46

Re: Check if admin is already logged in and question about session

Post by lucadambros » 02 Aug 2019, 15:12

I was creating the wrong type of middleware because I was trying to get the user before the response of the login.
I had to create a middleware like this one:

Code: Select all

public function handle($request, Closure $next)
    {
        $response = $next($request);

        // Perform action

        return $response;
    }

Post Reply