Laravel: share session data with multiple domains

I am creating an e-commerce application with multiple domains / multiple stores in Laravel and would like the user to be logged in when he or she changes from storage to storage.

But as far as I know, the Laravel Auth service keeps a registered user in a session, and sessions are not available to other domains.

Is there a way (possibly a package) to achieve this without leaving my application prone to possible security issues?

Thanks in advance!

+8
source share
5 answers
  • Capture Session ID Session::getId()in Domain A
  • HTTP POST B
  • B $sessionid_from_domainA = $_POST['session_from_A']
  • B Session::setId($sessionid_from_domainA)
  • B Session::start()
+6
  • A , <img src="https://DOMAINB.com/setcookie?id={{ Session::getId() }}" style="display:none;" />

  • B :

.

Route::get('setcookie', function(){
  Session::setId($_GET['id']);
  Session::start();
  return 'Cookie created';
});`
  1. , $user = Auth::User;
+5

, , http://laravel.io/forum/03-14-2014-multiple-domains-how-to-share-login

laravel /app/config/session.php cookie


Edit:

, .

cookie , . , 1.com, cookie 2.com, domain1.com -

<img src="http://www.domain2.com/create-cookie?param=hash">

domain2.com :

  • ,
    1. , (, ), , , , cookie
+2

, , , , . config/session.php :

<?php
/*
    |--------------------------------------------------------------------------
    | Session Cookie Domain
    |--------------------------------------------------------------------------
    |
    | Here you may change the domain of the cookie used to identify a session
    | in your application. This will determine which domains the cookie is
    | available to in your application. A sensible default has been set.
    |
    */

    'domain' => null,
?>

- . , store1.shops.com store2.shops.com, myshop.com shopsmart.com.

- , , , , . , OneLogin.

+1

, . Config/session.php .

: new.example.com test.example.com, example.com

'domain' => env ('SESSION_DOMAIN_URL', '. example.com')

The solutions there helped me, in particular, setting up the domain and then clearing my browser cookies. cache.

0
source

All Articles