当我显示myprojectdomain / home侧边栏但是当我在模块myprojectdomain / systemusers时,侧边栏不是

My logincontroller is in the path

app\Http\Controllers\Auth\LoginController.php

and I have this two method containing the following code:

public function authenticated(Request $request, $user)
{
    $user      = Auth::user();
    $user_role = UserRole::where('user_id', $user->id)->with(['role'])->first();
    $menu_role = MenuRole::where('role_id', $user_role->role_id)->with('menu')->get();

    # Add user role to session
    session(['role' => $user_role->role->name]);

    foreach ($menu_role as $key => $value) {
        if ($value->menu->hidden == 'false') {
            if ($value->menu->parent_id == 0) {
                $this->parent_menu[$value->id] = Menu::where('id', $value->menu_id)->get()->first();
            } else {
                $this->child_menu[$value->id] = Menu::where('id', $value->menu_id)->get()->first();
            }
        }
    }

    self::buildMenu();
}

and

private function buildMenu()
{
    $data = "";

    foreach ($this->parent_menu as $key => $pm) {
        $data .= '<a href="'.$pm->url.'" data-id="'.$pm->id.'"> '.$pm->label.' </a>';
        $data .= '<ul class="parent-menu-label">';
            foreach ($this->child_menu as $kkey => $cm) {
                if ( (string) $pm->id == $cm->parent_id) {
                    $data .= '<li class="child-menu-label">';
                        $data .= '<a href="'.$cm->url.'" data-id="'.$cm->id.'"> '.$cm->label.' </a>';
                    $data .= '</li>';
                }
            }

        $data .= '</ul>';
    }

    session(['sidebarmenu' => $data]);
}

In the above code, I stored the role name and menu in session

and in the master.blade.php

I display it in sidebar this way

{!! session('sidebarmenu') !!}

master is located here resources\views\layouts\master.blade.php

Now I have system users module

route is define here Modules\SystemUsers\start.php

and it contains route

Route::resource('systemusers', 'Modules\SystemUsers\Http\Controllers\SystemUsersController');

and I have controller here Modules\SystemUsers\Http\Controllers\SystemUsersController.php

has method that return index

public function index()
{
    return view('systemusers::index');
}

The index is located here Modules\SystemUsers\Resources\views\index.blade.php and this extends to the master.blade.php

The problem when I'm myprojectdomain/home sidebar is shown but when I'm in the module myprojectdomain/systemusers the sidebar is not, the session is null.

Why is it null when I'm in the module which extend to the master.blade.php that is outside the module?

and is session supposed to be global? it should be accessed anywhere?

can someone explain to me this and give a solution?

PS

I am using this package to create module. https://nwidart.com/laravel-modules/v3/introduction