private void AddCookieToHttpContext(HttpContext httpContext, IDataProtectionProvider eProvider, bool keepOwnPermissions = false) { var data = new ImpersonationData("differentUserId", "*****@*****.**", keepOwnPermissions); httpContext.AddRequestCookie("UserImpersonation", eProvider.CreateProtector(_cookieEncryptPurpose).Protect(data.GetPackImpersonationData())); }
internal static RequestTelemetry WithAuthCookie(this HttpContext context, string cookieString) { var requestTelemetry = new RequestTelemetry(); context.AddRequestCookie( new HttpCookie( RequestTrackingConstants.WebAuthenticatedUserCookieName, HttpUtility.UrlEncode(cookieString))) .AddRequestTelemetry(requestTelemetry); return(requestTelemetry); }