会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
小迪的Blog
学习ing...(注明:该Blog中的任何信息都非原创,只是作为个人的阅读笔记)
博客园
首页
新随笔
新文章
联系
订阅
管理
按照选定时间保存cookie
前台:
<
asp:dropdownlist
id
="remrember"
runat
="server"
>
<
asp:ListItem
Value
="0"
Selected
="True"
>
不保存
</
asp:ListItem
>
<
asp:ListItem
Value
="1"
>
保存一天
</
asp:ListItem
>
<
asp:ListItem
Value
="30"
>
保存一月
</
asp:ListItem
>
<
asp:ListItem
Value
="365"
>
保存一年
</
asp:ListItem
>
</
asp:dropdownlist
>
后台:
public
void
AddLoginCookie(
int
day)
{
HttpCookie cookie
=
new
HttpCookie(
"
remrember
"
);
cookie.Values.Add(
"
userName
"
,Session[
"
userName
"
].ToString());
cookie.Expires
=
DateTime.Now.AddDays(day);
Response.AppendCookie(cookie);
}
使用:
if
(remrember.SelectedValue
!=
"
0
"
)
AddLoginCookie(Convert.ToInt32(remrember.SelectedValue));
posted on
2005-03-17 17:24
小迪
阅读(
954
) 评论(
0
)
收藏
举报
刷新页面
返回顶部