Пример #1
0
        private static void AcquireSession(Basics.Context.IHttpRequest request, out Basics.Session.IHttpSession session)
        {
            string sessionCookieKey =
                Configurations.Xeora.Session.CookieKey;

            Basics.Context.IHttpCookieInfo sessionIdCookie =
                request.Header.Cookie[sessionCookieKey];
            request.Header.Cookie.Remove(sessionCookieKey);

            SessionManager.Current.Acquire(sessionIdCookie?.Value, out session);
        }
Пример #2
0
        public HttpContext(
            string contextId,
            bool secure,
            Basics.Context.IHttpRequest request,
            Basics.Context.IHttpResponse response,
            Basics.Session.IHttpSession session,
            Basics.Application.IHttpApplication application)
        {
            this.UniqueId = contextId;
            this.HashCode =
                this.GetOrCreateHashCode(ref request);
            this.Request     = request;
            this.Response    = response;
            this.Session     = session;
            this.Application = application;

            ((HttpResponse)this.Response).SessionCookieRequested +=
                skip =>
            {
                if (skip)
                {
                    return(null);
                }

                if (this.Session.Keys.Length == 0)
                {
                    return(null);
                }

                // Create SessionCookie
                string sessionCookieKey =
                    Basics.Configurations.Xeora.Session.CookieKey;
                Basics.Context.IHttpCookieInfo sessionIdCookie =
                    this.Response.Header.Cookie.CreateNewCookie(sessionCookieKey);
                sessionIdCookie.Value    = this.Session.SessionId;
                sessionIdCookie.Expires  = this.Session.Expires;
                sessionIdCookie.SameSite = secure ? Basics.Context.SameSiteTypes.None : Basics.Context.SameSiteTypes.Lax;
                sessionIdCookie.Secure   = secure;
                sessionIdCookie.HttpOnly = true;

                return(sessionIdCookie);
            };
        }