I’m a Laravel developer. I develop one ecommerce plugin with Laravel and I just want to combine WordPress with Laravel. So I need to share or make common login session between Laravel and WordPress.
How could I implement this? And are there special plugins available for this? Or could I use laravel-Auth?
The right way of doing it is to Have a Laravel (or WordPress) as an Auth server
And create like an SSO plugin.
I was doing the same with NodeBB Forum login from Laravel.
So you have all users in laravel (Registration and etc)
and if they want to login to WordPress they login to Laravel App and give permission to login to wordpress.
Think of it Like you add
Facebook Login to your site
Reading more for wordpress SSO
But to play with session and cookies it can be security issues.
Hope Helped.
Enabling Single-Sign-On in WordPress took me 18+ hours of struggle but might take you only a few minutes:
I experimented with all sorts of things: Laravel Passport (OAuth2), OpenID Connect, etc.
But the only solution I could get to work was to have the WordPress login page redirect to an auth-protected Laravel route that generates a JWT (JSON Web Token) and redirects back to a special callback URL on WordPress that either creates a new user or logs in an existing user.
It works well.
And then edit its auth.php to be this:
This belongs in functions.php of your theme in WordPress: