Capturing some session data in the encoder

I save some data in the session and some moments on my sites, I give the user the ability to delete certain parts of the session based on the array key, the array that I get when I do,

print_r($this->session->userdata('shortlist'); this leaves me with the following output:

 Array ( [0] => Array ( [id] => 40 [name] => Namey Name [location] => location is a place [talent] => voice over [image] => ./media/uploads/headshots/width_60_249613_10150280293315435_717615434_9570480_8341358_n.jpg ) ); 

How to remove this from my list session? I tried to do the following, but to no avail,

unset($this->session->userdata('shortlist')[0]);

+6
source share
1 answer

You can use this:

 $this->session->unset_userdata('some_name'); 

For more information:

http://codeigniter.com/user_guide/libraries/sessions.html

EDIT: after the comment: you can do something like this -

 $shortlist = $this->session->userdata('shortlist'); unset($shortlist[0]); $this->session->set_userdata('shortlist',$shortlist); 
+14
source

Source: https://habr.com/ru/post/900531/


All Articles