Laravel difference between session :: flash and request-> session-> flash

I wonder what is the difference in performance and usage?

public function delete(){
    \Session::flash('success', __('common.message.success.delete'));
}

      

against

public function delete(){
    $request->session()->flash('success', __('common.message.success.delete'))
}

      

please explain this with an open example. which one provides the best performance and which one is used in a session?

+3


source to share


1 answer


They are just different ways to access your application session object. With the help laravel

you can access the application session

  • Using the session facade as Session::

  • Using the request's

    session method$request->session()



You can read the laravel docs for session here . Hope this helps!

+2


source







All Articles