Answer the question
In order to leave comments, you need to log in
Laravel 5.2. Why don't sessions work in custom classes?
When saving sessions with any driver and getting it into controllers everything works. However, if you get the session value in a custom (non-controller) class, then an empty string is displayed.
If who faced, in what there can be a business?
Answer the question
In order to leave comments, you need to log in
So you run the script from the console, of course, that not only sessions are not available to you, but also cookies, and user $_SERVER variables (IP, user agent, etc.), and much more, because there is no user at all.
Why use custom classes? This time.
Check out the namespaces. This is two.
Forget all constructions of inclusions. Autoload is our everything. It's three.
Do not forget to include our sessions in the class, or use the session class from the root namespace (with a slash at the beginning). This is four.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question