Have been using Laravel for several months now and once an user logs in the application create a session user information with no issue.
Now, I want to keep track of a fiscal year that an user selected and keep it as a session value. The fiscal year value can change, but not often. However, in two cases, it frequently looses the session value.
- Case I: when making highly intensive ajax calls like Datatables. I believe the solution for this is using 'post' instead of get. If there is a better solution, please let me know.
2 Case II: When making an insert statement using ajax, it looses the fiscal_year session value. Listed below is my code and if there is a better way, please let me know.
if(Session::has('test_fiscal_year')) {
$fiscal_year = Session::get('test_fiscal_year');
}
else
//if the session test_fiscal_year is blank.
{
$fiscal_year_max = Select from a table.fiscal_year
//Session::put('test_fiscal_year', $fiscal_year_max);
session(['test_fiscal_year' => $fiscal_year_max]);
$fiscal_year = Session::get('test_fiscal_year');
Session::save();
}
For Case II, sometimes fiscal year comes back blank. There is a central application that uses fiscal year so is there a better way, maybe passing the fiscal year value instead of setting and getting session value for the fiscal year? The application makes lots of ajax calls.
I've tried used both file and cookie method for storing session value.
Thank you.