• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't unset session variable

I have a function that deletes a file and then attempts to unset it from a session variable like so

function removePrescription($id, $item)

    $fileToRemove = $this->session->userdata['prescription_details'][$id][$item]['prescriptionName'];

    unlink("./active/" . $fileToRemove);

    $this->session->set_userdata['prescription_details'][$id][$item]['prescriptionName'] = '';

    redirect($this->aData['base_url'] . 'checkout/basket');

The function removes the file okay but when it tries to unset the session variable I get this error.

Undefined property: CI_Session::$unset_userdata

Does anyone know what I'm doing wrong?

Thanks for any help!

[eluser]Jason Stanley[/eluser]
You aren't using the session library as intended. Typically you call the set_userdata function. You appear to be specifying a class variable.

You want to do something like this.

$details = $this->session->userdata('prescription_details');
$details['prescription_details'][$id][$item]['prescriptionName'] = '';
$this->session->set_userdata('prescription_details', $details);

Ah, I get it now. Cheers bud!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.