none
[求救]怎么在两个项目之间读取cookie RRS feed

  • 问题

  • 我的两个网站 部署在同一个站点的两个虚拟目录中

     他们之间cookie 却读取不到

     我在主站写的cookie:

     

    //记录用户信息入cookie和session
            /// <summary>
            /// 记录用户信息入cookie和session
            private void RecordMemInfo(string MemCode,string MemMail,string MemMobile,string Pwd,string NickName,string CityCode,string MemPic,string ViewNum)
            {
                //写Cookie和Session
                string CurrentDomain = (new PublicData()).GetWebSet("IowWEB", "CurrentDomain");
                //HttpCookie MemCookie = new HttpCookie("MemberInfo");
                HttpCookie MemCookie = new HttpCookie("MI");
                MemCookie.Domain = CurrentDomain;

                string MemInfo = MemCode + "|" + MemMail + "|" + MemMobile + "|" + Pwd;
                MemCookie.Value = (new CSOperate.InfoEncrypt()).MemInfoSetCookie(MemInfo);
                //MemCookie.Values["MemCode"] = MemCode;
                //MemCookie.Values["Mail"] = MemMail;
                //MemCookie.Values["Mobile"] = MemMobile;
                //MemCookie.Values["Pwd"] = Pwd;

                MemCookie.Expires = DateTime.Now.AddMonths(1); //cookie一个月有效
                Response.AppendCookie(MemCookie);

               }

    在另一个网站是这样读的

     string CurrentDomain = (new PublicData()).GetWebSet("IowWEB", "CurrentDomain");        
                HttpCookie MemCookie = new HttpCookie("MI");
                MemCookie.Domain = CurrentDomain;

                if (System.Web.HttpContext.Current.Request.Cookies["MI"] != null)
                {
                    string MemCode = "";
                    string Mail = "";
                    string Mobile = "";
                    string Pwd = "";
                    string[] MemInfo = (new IOWWEB.CSOperate.InfoEncrypt()).MemInfoGetCookie(System.Web.HttpContext.Current.Request.Cookies["MI"].Value.ToString());
                    MemCode = MemInfo[0];
                    Mail = MemInfo[1];
                    Mobile = MemInfo[2];
                    Pwd = MemInfo[3];

    可是

    System.Web.HttpContext.Current.Request.Cookies["MI"]  总是为空!

      请各位高手,斑竹,帮忙看看应该怎么解决

     

     是我的代码错了还是其他问题

     

    2008年7月30日 8:51

答案

全部回复