必须设置同一个域
写Cookie的代码
1HttpCookie userEmailCookie = new HttpCookie("GCEmail");
2 userEmailCookie.Value = email.ToString();
3 //userEmailCookie.Expires = DateTime.Now.AddYears(1); //浏览器关闭,cookie自动过期
4 userEmailCookie.Domain = domain;
5 HttpContext.Current.Response.Cookies.Add(userEmailCookie);
6
7 HttpCookie userIdCookie = new HttpCookie("GCUserID");
8 userIdCookie.Value = userId.ToString();
9 userIdCookie.Expires = DateTime.Now.AddYears(1);
10 userIdCookie.Domain = domain;
11 HttpContext.Current.Response.Cookies.Add(userIdCookie);
12
13 HttpCookie lastLoginTime = new HttpCookie("LastLoginTime");
14 lastLoginTime.Value = DateTime.Now.ToString();
15 //lastLoginTime.Expires = DateTime.Now.AddYears(1);
16 lastLoginTime.Domain = domain;
17 HttpContext.Current.Response.Cookies.Add(lastLoginTime);
18
19 HttpCookie userRemark = new HttpCookie("GCRemark");
20 userRemark.Value = userRemarkInfo;
21 //userRemark.Expires = DateTime.Now.AddYears(1);
22 userRemark.Domain = domain;
23 HttpContext.Current.Response.Cookies.Add(userRemark);
2 userEmailCookie.Value = email.ToString();
3 //userEmailCookie.Expires = DateTime.Now.AddYears(1); //浏览器关闭,cookie自动过期
4 userEmailCookie.Domain = domain;
5 HttpContext.Current.Response.Cookies.Add(userEmailCookie);
6
7 HttpCookie userIdCookie = new HttpCookie("GCUserID");
8 userIdCookie.Value = userId.ToString();
9 userIdCookie.Expires = DateTime.Now.AddYears(1);
10 userIdCookie.Domain = domain;
11 HttpContext.Current.Response.Cookies.Add(userIdCookie);
12
13 HttpCookie lastLoginTime = new HttpCookie("LastLoginTime");
14 lastLoginTime.Value = DateTime.Now.ToString();
15 //lastLoginTime.Expires = DateTime.Now.AddYears(1);
16 lastLoginTime.Domain = domain;
17 HttpContext.Current.Response.Cookies.Add(lastLoginTime);
18
19 HttpCookie userRemark = new HttpCookie("GCRemark");
20 userRemark.Value = userRemarkInfo;
21 //userRemark.Expires = DateTime.Now.AddYears(1);
22 userRemark.Domain = domain;
23 HttpContext.Current.Response.Cookies.Add(userRemark);
这里设置的域是有意义的,比如 你的域名为www.111.com
你的asp程序和asp.net程序都放在上面
那么,你那个设置域的地方都写 www.111.com 即可