1 | static int serveHttp_cookieHandling_defaultDays = 365; |
2 | static S serveHttp_cookieHandling_defaultCookieName = "cookie"; |
3 | sbool serveHttp_cookieHandling_verbose; |
4 | |
5 | // returns cookie (may be empty if client doesn't accept cookies) |
6 | static S serveHttp_cookieHandling() { |
7 | NanoHTTPD.IHTTPSession session = NanoHTTPD.currentSession.get(); |
8 | NanoHTTPD.CookieHandler cookies = session.getCookies(); |
9 | S cookie = cookies.read("cookie"); |
10 | if (cookie == null) { |
11 | if (empty((S) mapGet(MyHTTPD_headers!, "x-no-cookies"))) { |
12 | cookie = randomID(20); |
13 | if (serveHttp_cookieHandling_verbose) |
14 | print("New cookie."); |
15 | } |
16 | } |
17 | if (serveHttp_cookieHandling_verbose) |
18 | print("Cookie: " + cookie); |
19 | if (nempty(cookie)) |
20 | cookies.set("cookie", cookie, serveHttp_cookieHandling_defaultDays); |
21 | ret cookie; |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011963 |
Snippet name: | serveHttp_cookieHandling |
Eternal ID of this version: | #1011963/2 |
Text MD5: | 78f87f9bf8ca3767cfe192cf723a5c18 |
Author: | stefan |
Category: | eleu / javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-11-14 00:20:26 |
Source code size: | 830 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 473 / 523 |
Version history: | 1 change(s) |
Referenced in: | [show references] |