I'm currently attempting to extend the session facade, so instead of using Session::put('company', $company);
throughout my app, I'm using Session::setCurrentCompany($company);
and so on. To accomplish this, I extended \Illuminate\Session\SessionManager to add a few methods.
public function preferenceTimeZone()
{
return $this->get('preferenceTimeZone', App::make('DateTimeZone', ['America/New_York']));
}
public function setPreferenceTimeZone(DateTimeZone $timeZone)
{
$this->set('preferenceTimeZone', $timeZone);
}
With this method, I'm able to define my session variables and do Session::all();
and see every variable that has been set on the same page . Utilizing $this->get()
is the exact same as calling Session::get()
, or at least should be. However when I redirect the page, any variables set with my special methods are not saved, whereas those defined with Session::set()
or Session::put()
save just fine.
Any ideas on why this would be the case?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community