Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1002155 // Cookie-Based Session Test Bot

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1068L/7K/24K).

!752

static O mainBot;

static S cookieName = "deh-cookie";
static int cookieDays = 32;

static int cookieCounter = 1;

p {
  load("cookieCounter");
}

static synchronized S html() {
  O cookies = call(mainBot, "getCookies");
  S cookie = cast call(cookies, "read", cookieName);
  boolean isNew = false;
  if (cookie == null) {
    isNew = true;
    cookie = "Cookie " + (cookieCounter++);
    save("cookieCounter");
    call(cookies, "set", cookieName, cookie, cookieDays);
  }
  ret "Hello! Your " + (isNew ? "new " : "recurring ") + "cookie is: " + cookie;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002155
Snippet name: Cookie-Based Session Test Bot
Eternal ID of this version: #1002155/1
Text MD5: 8080fc083c985ff050fc95c2b599b5e8
Transpilation MD5: e215f2cdfa55013e9b5384376de5406f
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-22 17:26:20
Source code size: 586 bytes / 25 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 652 / 1167
Referenced in: [show references]