public override string GetSessionId(IHttpPhpContext webctx) { if (_lazyid == null) { // obtain the ID from cookies: var sessid = ((Context)webctx).Cookie[GetSessionName(webctx)]; if (Operators.IsEmpty(sessid)) { _isnewsession = true; if (_handler is SessionIdInterface idinterface) { _lazyid = idinterface.create_sid(); } else { _lazyid = session_create_id(); } webctx.AddCookie(GetSessionName(webctx), _lazyid, null); // TODO: lifespan } else { _isnewsession = false; _lazyid = sessid.ToStringOrThrow((Context)webctx); } } Debug.Assert(_lazyid != null); return(_lazyid); }
public override void Abandon(IHttpPhpContext webctx) { if (!_isnewsession) { webctx.AddCookie(GetSessionName(webctx), string.Empty, DateTimeOffset.UtcNow); } // destroy _handler.destroy(GetSessionId(webctx)); }
public override bool Persist(IHttpPhpContext webctx, PhpArray session) { webctx.AddCookie(GetSessionName(webctx), _lazyid, null); // TODO: lifespan // var handler = GetSerializeHandler((Context)webctx); // return // 1. write (_handler.write(GetSessionId(webctx), handler.Serialize((Context)webctx, (PhpValue)session, default(RuntimeTypeHandle))) && // 2. close _handler.close()); }