php - Can i use the below to unset several sessions -


i have several sessions this:

$_session['search']['max'] $_session['search']['order'] 

currently, unset each 1 of them separate statement:

if(isset($_session['search']['max']) && $_session['search']['max'] != ''){         unset($_session['search']['max']);     } if(isset($_session['search']['order']) && $_session['search']['order'] != ''){         unset($_session['search']['order']);     } 

my question - can use below general unset statement instead of having separate statement each session:

if(isset($_session['search']) && $_session['search'] != ''){             unset($_session['search']);         } 

are there advantages of declaring each unset statement separately?

note: need unset them @ same time, meaning not need keep 1 or more use again, therefore believe 1 statement should need sure not missing out anything.

thank all!

i have several sessions this:

nope. have 1 session. variables.

my question - can use below general unset statement instead of having separate statement each session variable:

  if(isset($_session['search']) && $_session['search'] != ''){         unset($_session['search']);     } 

you can. it's normal array. , unset($a) same $a = null, code just:

if(isset($_session['search']) && $_session['search'] != ''){     $_session['search'] = null; } 

meaning every element of $_session['search'] array discarded.

however not unsetting session!
session still live, discard of variables inside session!

are there advantages of declaring each unset statement separately?

there is. have control of variables stay (like, "i want , b stay, unset c , d"). if "nah, i'm sure don't need of them", can unset them in bulk , there nothing wrong that.


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -