L
L
lolrofl012018-09-12 10:48:51
Laravel
lolrofl01, 2018-09-12 10:48:51

How to work with the session in Laravel when loading the site?

Couldn't think of a better title. The point is this. When loading the site, I should have a check to see if the user has info on his region in the session. And if not - run the definition of the region. At the end - write it to the session. And some other functions that work in a similar way - every time the site loads. I know that a service provider is used for such purposes - but it does not know how to work with the session for the reason that the session is loaded, as I understand it, after the provider. There is a composer - but here it is necessary to specify which template to include the necessary functionality when loading, you can write * but I'm not sure that this will be true. So how do I organize my work the way I need it? Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2018-09-12
@lolrofl01

If I understand correctly, then you need to do it through Middleware .
We just write Middleware that will check sessions and do the right things.
Then we hang this Middelware on the desired route \ group of routes and that's it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question