Updated after some research
After some research I conclude that, my sessions are not maintained until I save them explicitly, below code works well, but WHY???? Ref here
Session::put('lets_test', 2);
Session::save();
Old Question
I'm new to laravel 5.3, and stuck at a problem. My Laravel Session or Flash messages are not expiring they display each time page is reloaded, until I use Session::flush()
Below is my controller code
<?php
namespace App\Http\Controllers;
use Session;
use Auth;
use Illuminate\Http\Request;
use App\User;
use App\Hospital;
use App\Wpr;
use Helper;
class OperatorController extends Controller
{
public $user_detail;
public function __construct()
{
$this->middleware('auth');
$this->middleware('operator');
}
public function store (Request $request){ //Form is being submitted here
//My logic here
Session::flash('user_message', 'Thank You');
return redirect('/operator/wpr');
}
}
I've also used Session::set('user_message', 4);
and blade view
@if(Session::has('user_message'))
<div class="message animated tada">
{{ Session::get('user_message') }}
</div>
@endif
I've tried with Session::forget('user_message')
but no luck.
Updating my post after some research. I've got somewhat close to my problem by reading this post on stack because this question is exactly same to my problem but unfortunately it still persists, I've changed my session storage from file to database (in case file permissions to storage directory). What might be other possibilities?
Please help, thanks in advance.