登录时怎么把用户名赋给cookie

[复制链接]
查看11 | 回复2 | 2008-10-25 10:52:42 | 显示全部楼层 |阅读模式
获取cookie,
HttpCookie cookie = Request.Cookies["user"];
value1 = cookies.Values["name"];
这样好像不行

回复

使用道具 举报

千问 | 2008-10-25 10:52:42 | 显示全部楼层
Cookie的用法也和ASP中差不多。比如我们建立一个名为user,值为111的cookieHttpCookie cookie = new HttpCookie("user");cookie.Value = "111";Response.AppendCookie(cookie);我们取出Cookie值也很简单HttpCookie cookie = Request.Cookies["user"];cookieValue = cookie.Value;有时候我们想在一个Cookie中储存多个信息,那也没有问题。比如我们在名为user的cookie下加多个信息HttpCookie cookie = new HttpCookie("us...
回复

使用道具 举报

千问 | 2008-10-25 10:52:42 | 显示全部楼层
//保存的登陆名 Response.Cookies["LoginName"].Value = "用户名"//设置过期时间为一天 Response.Cookies["LoginName"].Expires = DateTime.Now.AddDays(1);...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行