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

#1
[eluser]Unknown[/eluser]
I have a function that deletes a file and then attempts to unset it from a session variable like so

Code:
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!




#2
[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.

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

#3
[eluser]Unknown[/eluser]
Ah, I get it now. Cheers bud!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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