I am facing one issue. I am using Laravel 5.2 and i have put some data in session. After that I have kept die
and session can't be accessed in another function. But when i remove die
it is running fine. But I want to store data in session even i keep die
.
Here is my code:
public function session_test(Request $request){
$test = "live"
Session::put('filterdata',$test);
die;
}
public function session_get(Request $request){
echo Session::get('filterdata');
}
Please help me in figuring out the issue.
If you want to remove session variable use this way.
public function session_test(Request $request){
$test = "live"
Session::put('filterdata',$test);
}
public function session_get(Request $request){
echo Session::get('filterdata');
Session::forget('filterdata');
}
I have faced this problem in my one of functionality. I have solved after lot of hour using checking some laravel documentation about session.
You can do use this function before exit or die function when you have to use Session::put, Session::remove, Session::forget
public function session_test(Request $request){
$test = "live"
Session::put('filterdata',$test);
Session::save();
die;
}
public function session_get(Request $request){
echo Session::get('filterdata');
}