static int serveHttp_cookieHandling_defaultDays = 365; static S serveHttp_cookieHandling_defaultCookieName = "cookie"; sbool serveHttp_cookieHandling_verbose; // returns cookie (may be empty if client doesn't accept cookies) static S serveHttp_cookieHandling() { NanoHTTPD.IHTTPSession session = NanoHTTPD.currentSession.get(); NanoHTTPD.CookieHandler cookies = session.getCookies(); S cookie = cookies.read("cookie"); if (cookie == null) { if (empty((S) mapGet(MyHTTPD_headers!, "x-no-cookies"))) { cookie = randomID(20); if (serveHttp_cookieHandling_verbose) print("New cookie."); } } if (serveHttp_cookieHandling_verbose) print("Cookie: " + cookie); if (nempty(cookie)) cookies.set("cookie", cookie, serveHttp_cookieHandling_defaultDays); ret cookie; }