We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22424
    • 6 Posts
    I normally create and destroy messages for errors etc on each page load. What does Modx have built in for this if anything. Otherwise I am running into a problem. I create a session var the old fashioned way $_SESSION[’error’][] = "The error is here"; then I spit it out if($_SESSION[’error’]){ foreach($_SESSION[’error’] as $er) echo $er. And then I try to unset the error messages so they won’t build up and keep appearing. However by placing an unset($_SESSION[’error’]) at the bottom of the snippet that does the above the session gets cleared before it is every shown. What am I missing here?
      • 17846
      • 17 Posts
      $_SESSION[’error’] is an array itself, so with unset($_SESSION[’error’]) you unset the entire array. In the foreach loop you do: unset($_SESSION[’error’][$er]) for this specific array element $er only.