Answer the question
In order to leave comments, you need to log in
How to create a session key in laravel and save it?
Greetings.
The bottom line is this: I want to create a guestId session key for guests and write data to it.
Actually, if there is no key, then I generate it and do a put session.
But for some reason, with a new call to the code, guestId = null.
How to create a guest session in laravel?
$session_id = Session::get('guestId');
if (!$session_id) {
$session_id = substr(bin2hex(random_bytes(26)), 0, 26);
}
if (preg_match('/^[a-zA-Z0-9,\-]{22,52}$/', $session_id)) {
Session::put('guestId', $session_id);
} else {
dd('ops');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question