php - How i can use session in AppServiceProvider without using view composer?

one text

Solution:

You can't modify session data in a ServiceProvider. The StartSession middleware handles setting up the session in Laravel which is not executed until after all the ServiceProviders have been booted.

Also, the config helper doesn't effect session data, it updates config values like those that are in your config directory.

If you are trying to update session data, use session::set(key, value) instead.

Source