I am building an application on Drupal but due to some Drupal constraints and module customize limitation some features I need to build on Laravel framework. Drupal will be deployed on “example.com” and Laravel will be deployed on “subdomain.example.com” on the same server.
User authentication will be done through Drupal, so user session management will be maintained by Drupal. Now the twist is as I said some features will be developed on Laravel framework. Let’s take an example to make it more clear.
- User Logs in through Drupal
- There will be menu items for eg. A, B, C, D. Now A & B menu items have href link to example.com/a & example.com/b respectively but c & d have href link to subdomain.example.com/c & subdomain.example.com/d where C & d menu logic is built on Laravel application so when user click on c or d s/he will be redirected to Laravel application.
- Now my question is when navigating from Drupal to Laravel I need to authenticate the user on Laravel side also and once authentication is done on Laravel side new session for that user will be maintained on Laravel application.
Drupal will have its own session and Laravel will have its own session for the same user. How can we achieve this??
- I have one solution but is it the correct way to do?? If not then the best way to do this?
- I will be using JWT(JSON Web Token) to interact will Laravel application.
- for eg when user logs into Drupal JWT token will be generated and when the user navigates to Laravel application JWT token will be authenticated to check user’s identity on Laravel side and if it’s valid then the session will be maintained on Laravel. I will be using the same database for Drupal and Laravel