V
V
Vadim Gubiy2017-07-27 14:18:58
Laravel
Vadim Gubiy, 2017-07-27 14:18:58

How to extract session data correctly?

vkAL-QojS86hbEK7sQcrtg.png
Now I have these crutches :D
I'm sure that there is a simpler method) in the Laravel documentation I did not find how to extract session data by ID)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2017-07-27
@imbalancez

If I were you, I would look at how the framework itself solves this problem .
These are protected methods, so you may have to copy their code to yourself. I'm not sure if it's possible to replace this class with one inherited from it, or somehow get through to these methods without copying. But, in the worst case, these are three lines.
And Storeand EncryptedStoretake the session id as the last argument.
UPD :
Everything is much simpler:

/** @var \Illuminate\Session\Store $otherSession */
// Клонируем для того, чтобы не испортить оригинальную сессию текущего пользователя.
// Её, конечно, может и не быть, но клонирование всё равно позволит избежать проблем.
$otherSession = clone \Session::driver();

$otherSession->setId('your-id-here');
$otherSession->flush();
$otherSession->start();

dd($otherSession->all());

A
Alexander Aksentiev, 2017-07-27
@Sanasol

https://laracasts.com/discuss/channels/laravel/get...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question