JudgementDay Posted February 2, 2012 Share Posted February 2, 2012 I have one entity: $_SESSION['order']['content']['lol'] I then unset this entity: unset($_SESSION['order']['content']['lol']); I then try to unset the following as it is now empty (because I removed "lol"), buts its not working: if (empty($_SESSION['order']['content'])) { unset($_SESSION['order']['content']); } Does anyone know why and how I can go about getting it to unset? Quote Link to comment https://forums.phpfreaks.com/topic/256259-session-wont-unset/ Share on other sites More sharing options...
AyKay47 Posted February 2, 2012 Share Posted February 2, 2012 why would you assume that $_SESSION['order']['content'] is empty? was "lol" the only key/value in the array? have you tried print_r()ing or var_dump()ing the array to make sure that it is truly empty? The problem is not with unset(), the problem is that your condition is not returning true. Quote Link to comment https://forums.phpfreaks.com/topic/256259-session-wont-unset/#findComment-1313686 Share on other sites More sharing options...
JudgementDay Posted February 2, 2012 Author Share Posted February 2, 2012 Hi! var_dump()ing gives me: array(0) { } What do you mean by the problem is that your condition is not returning true? Quote Link to comment https://forums.phpfreaks.com/topic/256259-session-wont-unset/#findComment-1313688 Share on other sites More sharing options...
AyKay47 Posted February 2, 2012 Share Posted February 2, 2012 with "lol" removed, can you run this code and post the results. if (empty($_SESSION['order']['content'])) { unset($_SESSION['order']['content']); print_r($_SESSION['order']); } Quote Link to comment https://forums.phpfreaks.com/topic/256259-session-wont-unset/#findComment-1313697 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.