I have this code//TRIGGER MULTIPLE VIEWS, WALL AND FORUMif(isset($_COOKIE[projects-sorting])) {    $_SESSION['projectsDisplayMode'] = $_COOKIE[projects-sorting];}if(isSet($_GET['mode'])) {    $_SESSION['projectsDisplayMode'] = $_GET['mode'];}if(!isSet($_SESSION['projectsDisplayMode'])) {    $_SESSION['projectsDisplayMode'] = wall; //default is wall mode}$mode = $_SESSION['projectsDisplayMode'];setcookie(projects-sorting, $mode, time() + (86400 * 30), /); // 86400 = 1 dayWhich to me looks overly complicated, but it does work.What it does:Checks  if a specific cookie exists, if it does, set session variable projectsDisplayMode to whatever that cookie's content is.Check if _GET variable mode exists, if it does, set projectsDisplayMode to whatever that variable is (Would overwrite the last variable set if both exist)Last check if the session variable is set at all, if it's not set it to wall, as that is the default.Now set $mode (A specific page variable) to be processed a bit more to show the page properly.I'm not concerned with the afterwards processing, I just want to see if there is a better way that I can do the first bit that may be faster or more standard, or more pleasant to look at.
Seemingly complicated way of displaying page views
php
You only really need one if. IMO something like this would be easier to read.if(!empty($_GET['mode'])){    $mode = $_GET['mode'];}else{     $mode = !empty($_COOKIE[projects-sorting]) ? $_COOKIE[projects-sorting] : wall; }setcookie(projects-sorting, $mode, time() + (86400 * 30), /);$_SESSION['projectsDisplayMode'] = $mode;At the end of this, $_SESSION['projectsDisplayMode'] and $_COOKIE[projects-sorting] will always be the same value, so I would omit the former. You really shouldn't use session to store intermediate values anyway. You should be setting session to the value of $mode, not vice versa.