I'm working on a custom login controller that saves some query results on session using the global helper session() and then redirects to a page in the public folder to retrieve the session data, validate and display info.
I can set the variables using session()->put() succesfully and print them on the same controller (for testing purposes), but when I try to retrieve them on the public page it returns me the error "Call to undefined function session()".
I'm setting the variables like this, inside a controller where I also do a query to verify if username and password exist on the database.
session()->put(['usrNom'=>$checkLogin[0]->Nombre,
'usrPer'=>$perArray,
'usrEmail'=>$checkLogin[0]->Email,
'usrCve'=>$checkLogin[0]->ClaveEmpleado]);
I can print them successfully with their expected values on the same controller
print_r(session()->get('usrPer'));
print_r(session()->get('usrNom'));
Or it redirects to my public page
return Redirect::to('/modulos/dashboard');
In the index.php on the /modulos/dashboard public folder I have:
use Illuminate\Http\Request;
use Illuminate\Session;
$usrNom = session()->get('usrNom');
$usrPer = session()->get('usrPer');
echo "usr ".$usrNom;
However, instead of printing the values I get the error message
Fatal error: Uncaught Error: Call to undefined function session() in C:\Users\Lucania\Documents\Proyects\was\public\modulos\dashboard\index.php Stack trace: #0 {main}
The path is symlinked to the xampp/htdocs folders, is properly working and accesible via http://localhost/was/ instead of using php artisan serv
How can I make it work? I'm pretty new to Laravel, so I'm sure it's something I'm overlooking. Thanks for yout time.