Get the collection of Cookies in the Request

By [)ia6l0 iii

Use the Request.Cookies property to get the list of cookies

Code snippet below:

public static Dictionary<string, string> GetCookies()
        {
            Dictionary<string, string> cookies = new Dictionary<string, string>();
            foreach (string key in HttpContext.Current.Request.Cookies.AllKeys)
            {
                cookies.Add(key, HttpContext.Current.Request.Cookies[key].Value);
            }
            return cookies;
        }

Get the collection of Cookies in the Request  (722 Views)