奇迹冰霜巨蛛 首饰:phpwind 的 Cookie 运作(能实现者给50分)

来源:百度文库 编辑:高考问答 时间:2024/05/05 08:06:30
phpwind在登陆时会向客户端写Cookie
已后在每一页都会读取本地的Cookie进行分析是否已登陆和ID问题

现本人需要写一个网页程序,需要在外部页面登陆,向客户端写与phpwind一样的Cookie,并能读取其信息的php代码,在登陆后页面上的论坛连接一点就能实现已登陆效果,无需重新登陆

求高人指教,谢谢

回答小要求:
请直接作答,勿贴网址
代码要简单直接,不要太复杂,最好能加上注释

为防止第一作答者答案不满,没有第二作答者的现像造成分数浪费现像
采用作答后追加分数的办法,言出必行

private void btnLogin_Click(object sender, System.EventArgs e)
{

try
{

string userName=txtUserName.Text;
string password=txtPassword.Text;

if(userName.Equals(\"\"))
{
lbWarning.Text=TextProvider.GetTextProvider().GetText(\"login.need.username\");
return;
}
if(password.Equals(\"\"))
{
lbWarning.Text=TextProvider.GetTextProvider().GetText(\"login.need.password\");
return;
}

IWindsorContainer container = ContainerWebAccessorUtil.ObtainContainer();
IUserMgr userMgr=(IUserMgr)container[\"userMgr\"];

User u=userMgr.Login(userName,password);
if(u==null)
{
lbWarning.Text=TextProvider.GetTextProvider().GetText(\"login.error\");
return;
}
else
{
//lbWarning.Text=\"login ok!\";
userMgr.DoUpdateLastLoginTime(u.Id);
HttpContext.Current.Session[\"User\"] = u;
HttpContext.Current.Response.Redirect(\"index.aspx\", true);
}
}
catch(BusiException ex)
{
lbWarning.Text=ex.ShowMessage(ex);
}

}
}
}