Ejemplo n.º 1
0
        public async Task <UserSession> GetAsync(string id)
        {
            var value = await _distributedCache.GetStringAsync(GetSessionKey(id));

            var data = ProtectionUtils.DeserializeAndUnprotect <IDictionary <string, string> >(value, _dataProtector);

            return(new UserSession(id, data));
        }
        public string GetIdFromCookie()
        {
            if (!IsCookieExist)
            {
                return(null);
            }

            if (!HttpContext.Request.Cookies.TryGetValue(CookieName, out var value))
            {
                return(null);
            }

            return(string.IsNullOrWhiteSpace(value)
                ? null
                : ProtectionUtils.DeserializeAndUnprotect <string>(value, _dataProtector));
        }