<?php

$lang = $_POST["lang"] ?? exit(msg_error("Missing required field 'lang'") ?? 1);
$next = $_POST["next"] ?? ".";
setcookie("lang", $lang, time()+60*60*24*30);
header("Location: $next");