A
A
Alexander Razumov2016-04-06 22:46:10
Laravel
Alexander Razumov, 2016-04-06 22:46:10

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

2 answer(s)
T
Tesla, 2016-04-07
@razumovsu

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.

A
Andrzej Wielski, 2016-04-06
@wielski

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 question

Ask a Question

731 491 924 answers to any question