1. 程式人生 > >清除所有Cookie

清除所有Cookie

static caching ict color nbsp blog runtime enume spa

代碼

/// <summary>
        /// 清除所有Cookie
        /// </summary>
        public static void RemoveAll()
        {
            System.Web.Caching.Cache _cache = HttpRuntime.Cache;
            IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
            ArrayList al = new ArrayList();
            
while (CacheEnum.MoveNext()) { al.Add(CacheEnum.Key); } foreach (string key in al) { _cache.Remove(key); } }

清除所有Cookie