I am developing an API to manage active sessions in my Laravel application and would like to know if it is possible to create a session for a user.
I have the following code below, but it does not behave in the same way as a session created when accessing the system. It does not even create a session file in the “storage/framework/sessions” directory. Is there any way to create this “fake” session?
if($_SERVER['REQUEST_METHOD'] == 'POST') {
session_start();
foreach ($params['inputedData'] as $key=> $value) {
session([$key=> $value]);
}
$retorno["created_sessions"][$params['inputedData']->$nameUserSession] = ($params['inputedData']);
$retorno['metadados']["status"] = 200;
$retorno['metadados']["msg"] = "A sessão de " . $params['inputedData']->$nomeSessoesLogadas .
" foi criada com sucesso !";
session_write_close();
self::retornarOk(
$retorno,
$params['htmlEncodeDecodeRet'],
$params['tipoRetorno'],
$params['identarRetorno']
);
}