System.Web.SessionState.SessionStateModule.IsCookieLess C# (CSharp) Method

IsCookieLess() static private method

static private IsCookieLess ( HttpContext context, System.Web.Configuration.SessionStateSection config ) : bool
context System.Web.HttpContext
config System.Web.Configuration.SessionStateSection
return bool
		internal static bool IsCookieLess (HttpContext context, SessionStateSection config) {
			if (config.Cookieless == HttpCookieMode.UseCookies)
				return false;
			if (config.Cookieless == HttpCookieMode.UseUri)
				return true;
			object cookieless = context.Items [CookielessFlagName];
			if (cookieless == null)
				return false;
			return (bool) cookieless;
		}

Usage Example

        public string GetSessionID(HttpContext context)
        {
            string ret = null;

            if (SessionStateModule.IsCookieLess(context, config))
            {
                string tmp = context.Request.Headers [SessionStateModule.HeaderName];
                if (tmp != null)
                {
                    ret = Decode(tmp);
                }
            }
            else
            {
                HttpCookie cookie = context.Request.Cookies [config.CookieName];
                if (cookie != null)
                {
                    ret = Decode(cookie.Value);
                }
            }

            if (ret != null && ret.Length > SessionIDMaxLength)
            {
                throw new HttpException("The length of the session-identifier value retrieved from the HTTP request exceeds the SessionIDMaxLength value.");
            }
            if (!Validate(ret))
            {
                throw new HttpException("Invalid session ID");
            }

            return(ret);
        }
All Usage Examples Of System.Web.SessionState.SessionStateModule::IsCookieLess