//session
//Set Session
Route::get('set-session', function(Request $request){
$request->session()->put('name', 'Kanha');
$request->session()->put('id', '1');
$request->session()->put('type', 'admin');
});
//Get Session
Route::get('get-session', function(Request $request){
$allSession = session()->all();
print_r($allSession);
});
//delete Session
Route::get('delete-session', function(Request $request){
//delete session by single key name
session()->forget('name');
session()->forget('id');
//after delete show all the session
//delete by a single array
session()->forget(['name' , 'id' , 'type' ]);
$allSession = session()->all();
print_r($allSession);
});
//session in view page - blade template
check a session exist or not = session()->has('user');
get session value by key = session()->get('user');
delete a session by key = session()->forget('name');
delete multiple in single array = session()->forget(['name' , 'id' , 'type' ]);
store one time in session = $request->session()->flash('key' , 'value');
0 Comments