我是靠谱客的博主 耍酷白羊,这篇文章主要介绍清除cookie,现在分享给大家,希望可以做个参考。


    private static void DetelteAllCookies(string domain)
    {
        if (HttpContext.Current.Request.Cookies["userToken"] == null)
        {
            string cookieName;
            int limit = HttpContext.Current.Request.Cookies.Count;
            for (int i = 0; i < limit; i++)
            {
                cookieName = HttpContext.Current.Request.Cookies[i].Name;
                HttpContext.Current.Response.Cookies.Remove(cookieName);
                HttpContext.Current.Response.Cookies[cookieName].Domain = domain;
                HttpContext.Current.Response.Cookies[cookieName].Expires = DateTime.Now.AddDays(-1);
                HttpContext.Current.Response.Cookies[cookieName].Value = null;
            }
        }
    }

转载于:https://www.cnblogs.com/libbybyron/p/4125878.html

最后

以上就是耍酷白羊最近收集整理的关于清除cookie的全部内容,更多相关清除cookie内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(113)

评论列表共有 0 条评论

立即
投稿
返回
顶部