unset session array |
[eluser]ranjitbd[/eluser]
//which one is correct to unset a full session array name $userdata? $this->session->unset($userdata); $this->session->unset_userdata($userdata);
[eluser]Dam1an[/eluser]
a) Why not carry this on in your other session thread b) Have you read the user guide? c) Where did you get the 'unset' function from? Cause it's not documented, and it's not in my copy of CI d) unset_userdata takes a string, which is the key to the var to unset, or an array, not the variable itself
[eluser]Phil Sturgeon[/eluser]
You can pass an array of all the bits of userdata you want to remove like this: Code: $this->session->unset_userdata(array('first_thing', 'second_thing', 'third_thing', 'etc')); That will replace all of the listed bits of session data with an empty string. Alternatively, you can kill the whole session. Code: $this->session->sess_destroy(); This will kill everything. Meaning you will need to create a new session to do anything useful. Final option. You should not be able to access the user data directly through the class, but as PHP 4 does not support public/private you can... Code: foreach (array_keys($this->session->userdata) as $key) That is a very bad way to do things, as it will break when/if CodeIgniter eventually move their libraries to PHP 5 syntax. That will not been soon (nor does it need to be) but will happen eventually. |
Welcome Guest, Not a member yet? Register Sign In |