diff --git a/session_dialog.php b/session_dialog.php index df5a5fd..bda09f4 100644 --- a/session_dialog.php +++ b/session_dialog.php @@ -276,6 +276,7 @@ function handle_postcode_modal($data) ]); exit(); } + $cookie_val = postcode_in_range($params["postcode"]).'|'.$params["postcode"].'|'.$straatnaam.'|'.$params["huisnummer"].'|'.$woonplaats.'|'; // 6. Succes: Sessie opslaan & response $_SESSION["postcode"] = $params["postcode"]; @@ -284,12 +285,18 @@ function handle_postcode_modal($data) $_SESSION["woonplaats"] = $woonplaats; $_SESSION["postcode_is_local"] = postcode_in_range($params["postcode"]); + setcookie("PPPR", $cookie_val, [ + 'expires' => time() + 3600, + 'path' => '/', + 'domain' => $_SERVER['SERVER_NAME'], + 'secure' => true, // Required for cross-origin fetch + 'httponly' => true, // Prevents JavaScript access (XSS protection) + 'samesite' => 'Lax' // Use 'None' for cross-origin, requires secure=true + ]); + echo json_encode([ "status" => "success", "message" => "all good", - "straatnaam" => $straatnaam, - "woonplaats" => $woonplaats, - "lokaal_tarief" => postcode_in_range($params["postcode"]), ]); exit(); }