日期:2014-05-18  浏览次数:20469 次

如何用cookie能记住密码。
就是在下次访问该网站是不用在登陆的,应该怎么实现这个功能啊!

------解决方案--------------------
那个不是记住密码 随便记录到cookie里面一个值

在页面中先判断 cookie中有没有这个值 如果有就把状态设为登陆就OK了
------解决方案--------------------
是的,楼上正解
------解决方案--------------------
//写入Cookie
protected void insertCookie_Click(object sender, EventArgs e)
{
HttpCookie hc = new HttpCookie( "myCookie ");
//单独值用
//hc.Value[ " "]
//集合值
hc.Values[ "name "] = "Jaewon ";
hc.Values[ "sex "] = "man ";
hc.Values[ "date "] = DateTime.Now.ToString();
//添加Cookie到集合中
Response.Cookies.Add(hc);
Response.Write( "写入成功! ");
}
//读取Cookie
protected void readCookie_Click(object sender, EventArgs e)
{
HttpCookie Gethc = Request.Cookies[ "myCookie "];
if (Gethc != null)
{
Response.Write(Gethc.Values[ "name "]);
Response.Write( " <br> " + Gethc.Values[ "sex "]);
Response.Write( " <br> " + Gethc.Values[ "date "]);
}
else
{
Response.Write( "Cookie值为空! ");
}
}
------解决方案--------------------
HttpCookie hc = Request.Cookies[ "user "];
if (!Object.Equals(hc, null))
{
return hc.Value;
}
return null;
------解决方案--------------------
呵呵,楼上的讲的正是.


------解决方案--------------------
mk