zoukankan
html css js c++ java
按照选定时间保存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));
查看全文
相关阅读:
c# 自定义事件和委托
C#委托之个人理解(转)
invokeRequired属性和 invoke()方法
.NET(C#)连接各类数据库
Mobile Web Development with ASP.NET 2.0
移动飞信WEB发送服务接口
4行C#代码打造专业数据库连接配置界面
domino 中 UniversalID 和NoteID的区别
VB中preserve的用法
LOTUS Note ID 剖析
原文地址:https://www.cnblogs.com/xiaodi/p/120539.html
最新文章
接口隔离原则(转)
跨数据库访问
sql中的时间函数
.net SQL依赖缓存
asp.net学习之SqlDataSource应用详解
使用AspNetPager让当前分类下的商品实现高效分页显示
终于可以折叠代码了
天蓝
[MSDN]ASP.NET 状态管理概述
通过用户控件中的事件传值给ASPX页面
热门文章
asp.net中的<%register %>
.net文件依赖缓存
为什么 OnCategorySelected="UCCategoryTree1_CategorySelected" 就能给UCCategoryTree1的CategorySelected事件赋值呢?
C#委托及事件
Tcp/Udp详解
C#中的delegate和event用法详解
C# Socket编程笔记(转)
自定义事件
[转载]DEV控件:gridControl常用属性设置
c# 窗体截图
Copyright © 2011-2022 走看看