Cookie在域中的读写实现顶级域共享的方法,有需要的朋友可以参考下。
///读写Cookie
////写入Cookies信息写入Cookies信息#region 写入Cookies信息
/**//**//**//// <summary>
/// 写入Cookies信息
/// </summary>
private void WriteCookies(string uname,string upwd)
{
//写入Cookies中帐户信息
// HttpCookieCollection Colcookies = Request.Cookies;
Colcookies = Request.Cookies;//获得Cookies集合
HttpCookie Cookies = new HttpCookie("IRMEmail"); //创建Cookies
Cookies.Value = uname; //设置Cookies值
Cookies.Domain = labDomain.Text.Trim(); //设置Cookies域
Colcookies.Add(Cookies); //加入Cookies集合
Response.Cookies.Add(Cookies);
//写入Cookies中密码信息
Cookies = new HttpCookie("IRMPassword");
Cookies.Value = upwd;
Cookies.Domain = labDomain.Text.Trim();
Colcookies.Add(Cookies);
Response.Cookies.Add(Cookies);
}
#endregion
读取Cookies信息读取Cookies信息#region 读取Cookies信息