vendredi 8 novembre 2019

How to share session from Laravel to WordPress

So, I have developed a Laravel website and then install a WordPress site onto public folder of the Laravel website.

Now, I need to get the Laravel session from the WP site. I've tried three ways to making this work but no luck.

  1. Inject the Laravel instance to WordPress > child-theme > functions.php by following this
  2. Using cURL to get Laravel session > auth()->user()
  3. Using Ajax to get Laravel session > auth()->user()

This issue probably is because to get the Laravel session, the Laravel need the cookie that was generated by the Laravel site.

Also, here is the case of how users access the WP site:

  1. User access the Laravel homepage first, then open the homepage of the WP site. Here, the Laravel session can be accessed, but, when user opens the page detail on the WP site, the Laravel session is null
  2. User access the WP homepage (e.g. https://website.com/blog). The WP site can get the Laravel session here, but, when the user opens the page detail (e.g. https://website.com/blog/kategory/post-slug), the Laravel session is null
  3. User access the WP page detail directly (e.g. https://website.com/blog/kategory/post-slug). The Laravel session is null.

I am using Laravel 5.5 and install the latest version of the WordPress site.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire