Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Note that these if blocks will execute as long as there is a value within the session variable, even if that value is false. Use if (isset($_SESSION['var']) && $_SESSION['var']) to prevent. Commented Feb 7, 2022 at 20:53
  • The first suggestion would work in some cases and in fact we use it sometimes, but in the case of a structure like the following, would be unwieldy: if ($_SESSION['a'] || $_SESION['b']) .... That is because in some instances there could be 20 or more such conditions. The second suggestion is ugly, but is in fact what we are doing now. However, with the syntactical sugar as follows: $_SESSION['a'] = $_SESSION['a'] ?? null; Commented Apr 12, 2022 at 22:25
  • @zoore i believe you mean deprecated Commented Oct 23, 2023 at 18:38
  • it make another problem, because passing null/empty values in php 8 is deprecated @jaypat32 - yes, I made a typo. Thank You. Commented Nov 6, 2023 at 12:43