Answer the question
In order to leave comments, you need to log in
Storing data in session in Laravel?
I wrote such a controller to work with the session.
class SessionsController extends Controller
{
public function start(Request $request)
{
$request->session()->regenerate();
$request->session()->put('start', Carbon::now());
return response()->json(['active' => true]);
//Я запускаю новую сессию и прописываю ей время старта
}
public function finish(Request $request)
{
$request->session()->put('finish', Carbon::now());
return response()->json(['active' => false]);
//Я делаю метку, что смена закрыта и прописываю ей время окончания
}
public function check(Request $request)
{
//для проверки открыта ли смена при первичном заходе на страницу
if ($request->session()->has('finish')) {
return response()->json(['active' => false]);
} else {
return response()->json(['active' => true]);
}
}
public function check_session(Request $request)
//кнопка для проверки содержания сессии...
{
return $request->session()->all();
}
}
Answer the question
In order to leave comments, you need to log in
1) payload - stuffing. What needs to be saved.
2) If you do session()->flush() after session()->regenerate() - what happens?
Well guys, what are the crutches, set up the session driver database
and it will be easier to live) and created_at will be updated_at
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question