Laravel

cross domain session laravel

Hi, In this tutorial I am going to explain how to make cross domain session in laravel .

In my previous tutorial i have explained how to make cross domain request using jquery ajax. Use Same ajax concept in laravel also.

One thing you need to follow for laravel.

Add your header in route.php

If you want to make cross domain registration and make login for both A and B domains, you need to use session variable.

But its little difficult make cross domain session storage for variables. Because session will not store between A and B domains.

Here, I will tell how cache works instead of sessions in laravel.

When CROS ajax performing I will store data’s in Cache like below and will reload my domain.

Laravel will maintain inbuild cache’s.



Once ajax request completed your data will be stored in table as well as cache.
After that relaod your page and add below to code in your routes.php.

It will check whether the cache are stored and will create login in A domain. You can write your code to make login for B domain. Now you can see your both domain registerd with same data and logged in.

Once your process completed delete the cache for should not affect other users.

Thanks!. If you like this article don’t forget to share and comment.