public static SessionPool FromJSON(string json) { SessionPool p = new SessionPool(); API.session_pool_init_from_json(p.d, tb(json)); p.check(); return(p); }
public static SessionPool FromConfig(string path) { SessionPool p = new SessionPool(); API.session_pool_init(p.d, tb(path)); p.check(); return(p); }
internal Session(SessionPool pool) { d = API.session_new(); API.session_init(d, pool.d); try { check(); } catch (Exception) { Close(); throw; } }
public static void Main(string[] args) { using (SessionPool pool = SessionPool.FromConfig(args[0])) { string state = ""; using (Session session = pool.Session()) { session.Load(state); session["x"] = "y"; session["y"] = "124"; session.SetExposed("y", true); foreach (string k in session.Keys) { Console.WriteLine("Got Key " + k); } session.Save(); foreach (Cookie c in session.Cookies) { if (c.Name == session.SessionCookieName) { state = c.Value; } Console.WriteLine("Got Cookie " + c); } } using (Session session = pool.Session()) { session.Load(state); session.SetExposed("y", false); session.Save(); foreach (Cookie c in session.Cookies) { if (c.Name == session.SessionCookieName) { state = c.Value; } Console.WriteLine("Got Cookie " + c); } foreach (HttpCookie c in session.HttpCookies) { Console.WriteLine("Got HttpCookie " + c.Name + " expires at " + c.Expires); } } } Console.WriteLine("Ok"); }