zoukankan      html  css  js  c++  java
  • 二级域名如何写cookie

    二级域名如何写cookie

    主站:www.zzm.com
    子站:shop.zzm.com
    <appSettings>
        <add key="EJJJCookieDomainName" value="zzm.com"/>
    </appSettings>

    两个项目下的web.config都写入这个节点

    写cookie的时候读取此节点的value,把cookie写在此域名下。二级域名也就写进cookie了。

     #region 写登录Cookie
            public static int WriteCookie(string UserID, string UserName,string UserType,bool remember)
            {
                HttpCookie userCookie = new HttpCookie("Deco");
                userCookie.Domain = System.Configuration.ConfigurationManager.AppSettings["EJJJCookieDomainName"].ToString();
                userCookie.HttpOnly = true;
                if(remember)
                {
                    userCookie.Expires = DateTime.Now.AddYears(1);
                }
                userCookie["DecoUName"] = HttpUtility.UrlEncode(UserName);
                userCookie["DecoUID"] = UserID;
                userCookie["DecoUType"] = UserType;  
                HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                HttpContext.Current.Response.Cookies.Remove("Deco");
                HttpContext.Current.Response.Cookies.Add(userCookie);
                return 1;

            }
            #endregion 

  • 相关阅读:
    C语言基础-第一章
    C语言基础-第三章
    C语言基础-第五章
    怎样在WIN7系统下安装IIS
    Asp.Net中使用水晶报表(下)
    Asp.Net中使用水晶报表(中)
    Asp.Net 中使用 水晶报表(上)
    A1112. Stucked Keyboard
    A1111. Online Map
    A1110. Complete Binary Tree
  • 原文地址:https://www.cnblogs.com/jimmychow/p/2354426.html
Copyright © 2011-2022 走看看