protected void Page_Load(object sender, EventArgs e) { using (Session s = pool.Session()) { s.Load(Request); string v = "0"; if (s.IsSet("x")) { v = s["x"]; } v = (int.Parse(v) + 1).ToString(); s["x"] = v; s.Save(Response); counter = v; } }
protected void Page_Load(object sender, EventArgs e) { using (Session session = pool.Session()) { session.Load(Request); StringBuilder final_result = new StringBuilder(); for (int i = 1;; i++) { string id = "_" + int2str(i); string op = Request.QueryString["op" + id]; if (op == null) { break; } string key = Request.QueryString["key" + id]; string val = Request.QueryString["value" + id]; string result = "ok"; switch (op) { case "is_set": result = session.IsSet(key) ? "yes" : "no"; break; case "erase": session.Erase(key); break; case "clear": session.Clear(); break; case "is_exposed": result = session.GetExposed(key) ? "yes" : "no"; break; case "expose": session.SetExposed(key, Int32.Parse(val) != 0); break; case "get": result = session[key]; break; case "set": session[key] = val; break; case "get_binary": result = toHex(session.GetBinary(key)); break; case "set_binary": session.SetBinary(key, fromHex(val)); break; case "get_age": result = int2str(session.Age); break; case "set_age": session.Age = Int32.Parse(val); break; case "default_age": session.SetDefaultAge(); break; case "get_expiration": result = int2str(session.Expiration); break; case "set_expiration": session.Expiration = Int32.Parse(val); break; case "default_expiration": session.SetDefaultExpiration(); break; case "get_on_server": result = session.OnServer ? "yes" : "no"; break; case "set_on_server": session.OnServer = Int32.Parse(val) != 0; break; case "reset_session": session.ResetSession(); break; case "csrf_token": result = "t=" + session.CSRFToken; break; case "keys": result = ""; string[] keys = session.Keys; for (int j = 0; j < keys.Length; j++) { if (result != "") { result += ","; } result += "[" + keys[j] + "]"; } break; default: result = "invalid op=" + op; break; } final_result.Append(int2str(i) + ":" + result + ";"); } session.Save(Response); message = final_result.ToString(); } }