//在 mm.p.cn登录页面。//web.config<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="UserLogin.aspx" path="/" protection="All" timeout="30" domain="p.cn"></forms>
</authentication>
//建立cookie
string username = "GUID=" + System.Guid.NewGuid() + ",SSID=" + Session.SessionID + ",USID=" + txtUserName.Text;
FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddHours(24), true, zid, FormsAuthentication.FormsCookiePath);
string cookiestr = FormsAuthentication.Encrypt(tkt);
HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
//userCookie.Value = hashTicket;
//userCookie.Expires = tichet.Expiration;
//ck.Domain = FormsAuthentication.CookieDomain;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
//在gg.p.cn下
//web.config
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="mm.p.cn/UserLogin.aspx" path="/" protection="All" timeout="30" domain="p.cn"></forms>
</authentication>
//读cookie
//方法一
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Request.Cookies[cookieName];
//Common.common.alert(authCookie.Value); if (authCookie != null)
{
try
{
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); string MyCookie = authTicket.UserData.ToString();
Common.common.alert(MyCookie);
}
catch (Exception ex)
{
return;
}
}//方法二
//判断用户是否登录
if (Page.User.Identity.IsAuthenticated)
{
FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity;
//不为空
pnlLoggedin.Visible = true;
lblUserName.Text = identity.Name;
}
方法一和二都得到那个cookie ,
<forms name=".ASPXAUTH" loginUrl="UserLogin.aspx" path="/" protection="All" timeout="30" domain="p.cn"></forms>
</authentication>
//建立cookie
string username = "GUID=" + System.Guid.NewGuid() + ",SSID=" + Session.SessionID + ",USID=" + txtUserName.Text;
FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddHours(24), true, zid, FormsAuthentication.FormsCookiePath);
string cookiestr = FormsAuthentication.Encrypt(tkt);
HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
//userCookie.Value = hashTicket;
//userCookie.Expires = tichet.Expiration;
//ck.Domain = FormsAuthentication.CookieDomain;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
//在gg.p.cn下
//web.config
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="mm.p.cn/UserLogin.aspx" path="/" protection="All" timeout="30" domain="p.cn"></forms>
</authentication>
//读cookie
//方法一
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Request.Cookies[cookieName];
//Common.common.alert(authCookie.Value); if (authCookie != null)
{
try
{
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); string MyCookie = authTicket.UserData.ToString();
Common.common.alert(MyCookie);
}
catch (Exception ex)
{
return;
}
}//方法二
//判断用户是否登录
if (Page.User.Identity.IsAuthenticated)
{
FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity;
//不为空
pnlLoggedin.Visible = true;
lblUserName.Text = identity.Name;
}
方法一和二都得到那个cookie ,
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货