I'm a beginner and I need to know please if there's any way to use sessions in laravel8 like those in PHP. I took a look at laravel's documentation, like $request->session().. but I didn't really get it so I'm asking you to help me please .
In PHP I use to do :
< ?php
session_start();
...
if(!empty( $_POST['name'])&&!empty( $_POST['lastName'])...)
{
$name= $_POST['name'] ;
$lastName= $_POST['lastName'];
$_SESSION['name']=$name;
$_SESSION['lastName']=$lastName;...
}
# Then I use $_SESSION['name'] in any file related to this project until this person log out.
?>
How can I use it in Laravel 8?
Here's where I need it : I have interface where the user can search for candidate using a word and a keyword
<div class="col-lg-6 col-md-6 col-sm-12 p-0">
input name="keyword" type="text" class="form-control search-slt" placeholder="Search...">
</div>
<div class="col-lg-3 col-md-3 col-sm-12 p-0">
<select class="form-control search-slt" id="exampleFormControlSelect1" name="key">
<option >Choose your search key</option>
<option value="name"> Name </option>
<option value="lastName">Last Name</option>
<option value="code"> Code </option>
</select>
CandidateController :
public function search(Request $request)
{
$data=$request->validate([
'keyword' => 'required',
'word' => 'required',]);
$keyword= $data['keyword'];
$key= $data['key'];
$candidate = candidate::where($key, $keyword)->get();
return view('candidate.list', compact('candidate'));
}
Now the problem is when I refresh the view candidate/list I get
The GET method is not supported for this route. I need a way to keep the IDS of those candidates, so the search function can find the candidates using these IDS and compact them and send it again to view('candidate.list') in a case the user refreshed the page. But then again I don't know what code to use to find a lot of candidates using their ids like $candidate = Candidate:find($id) if I have more than one ID and more than one candidate to find ?
How can I use it in Laravel 8 Please don't mind my ignorance I'm just a beginner Thank you in advance I appreciate your help