New session per subdomain!

Posted 9 months ago by Stank0V01

Hello im tryna make one auth session per domain! So here is more details.

I want to make something like that:

All of that sites have own session and when loggin in in one of it in another site you must loggin in again. So here is my routes


| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

Route::group(['domain' => env('PLAIN_URL')], function () {
    Route::get('/', '[email protected]')->name('home');
    Route::post('/gdpr', '[email protected]');

// Main site cart
    Route::group(['prefix' => 'cart'], function () {
        Route::post('/checkout', '[email protected]')->name('checkout');
        Route::get('/success', '[email protected]')->name('purchaseSuccess');
        Route::get('/failed', '[email protected]')->name('purchaseFailed');
        Route::put('/proccess', '[email protected]')->name('purchase');
        Route::get('/check', '[email protected]')->name('check');


// Shop things content
Route::group(['domain' => '{slug}.' . env('PLAIN_URL'), 'middleware' => 'ShopExist'], function () {
    Route::get('/', 'Shop\[email protected]');
    Route::get('/language/{lang}', 'Shop\[email protected]');
    Route::get('/currency/{currency}', 'Shop\[email protected]');
    Route::get('/category/{category}', 'Shop\[email protected]');

    Route::group(['prefix' => 'auth'], function () {
        Route::get('/login','Shop\[email protected]')->middleware('guest');
        Route::get('/logout','Shop\[email protected]')->middleware('auth');
        Route::post('/login','Shop\[email protected]')->middleware('guest');


My Session.php config


return [

    'driver' => env('SESSION_DRIVER', 'database'),

    'lifetime' => env('SESSION_LIFETIME', 120),

    'expire_on_close' => true,

    'encrypt' => true,

    'files' => storage_path('framework/sessions'),

    'connection' => null,

    'table' => 'sessions',

    'store' => null,

    'lottery' => [2, 100],

    'cookie' => 'myshopmcsession',

    'path' => '/',

    'domain' => env('PLAIN_URL'),

    'secure' => env('SESSION_SECURE_COOKIE', false),

    'http_only' => true,

    'same_site' => null,


So when you loggin in in one site to not log you in another!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.