mercredi 26 septembre 2018

Laravel - Array in session not destroying using session forget method

In my Laravel project I am storing array in to session. I tried to delete the whole array from session using session forget method, but it is not working. I can access sessions after session forget. Any help would be appreciated thank you.

Storing data in to session

$item = [
         'name' => 'Test',
         'normalIdSession' => 'Normal Data',
         'guestsSession' => '1',
         'amountSession' => '200'
        ];

$request->session()->put('item', $item);

Deleting session

if(session()->has('item'))
{

  $name            = session()->get('item.name');
  $normalIdSession = session()->get('item.normalIdSession');
  $guestsSession   = session()->get('item.guestsSession');
  $amountSession   = session()->get('item.amountSession');

  // Here data storing in to database and deleting sessions.
  session()->forget('item');
  dd($name); // Here I can access session data.
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Qa3eiK
via IFTTT

Aucun commentaire:

Enregistrer un commentaire