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!
Session::getId()
$sessionid_from_domainA = $_POST['session_from_A']
Session::setId($sessionid_from_domainA)
Session::start()
A , <img src="https://DOMAINB.com/setcookie?id={{ Session::getId() }}" style="display:none;" />
<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'; });`
$user = Auth::User;
, , 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 :
, , , , . config/session.php :
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.
store1.shops.com
store2.shops.com
myshop.com
shopsmart.com
- , , , , . , OneLogin.
, . 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.