zoukankan
html css js c++ java
Limiting Persistent Authentication Cookie Lifetime
void
Application_EndRequest(Object sender, EventArgs e)
{
//
Change the expiration date on outgoing persistent forms
//
authentication tickets to 24 hours hence.
HttpCookie cookie1
=
GetCookieFromResponse(
FormsAuthentication.FormsCookieName);
if
(cookie1
!=
null
&&
!
String.IsNullOrEmpty (cookie1.Value))
{
FormsAuthenticationTicket ticket1
=
FormsAuthentication.Decrypt(
Response.Cookies[FormsAuthentication.FormsCookieName].Value);
if
(ticket1.IsPersistent)
{
FormsAuthenticationTicket ticket2
=
new
FormsAuthenticationTicket (
ticket1.Version, ticket1.Name, ticket1.IssueDate,
DateTime.Now.AddHours (
24
),
//
New expiration date
ticket1.IsPersistent, ticket1.UserData,
ticket1.CookiePath
);
Response.Cookies.Remove(FormsAuthentication.FormsCookieName);
HttpCookie cookie2
=
new
HttpCookie(
FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket2));
cookie2.Expires
=
ticket2.Expiration;
Response.Cookies.Add(cookie2);
}
}
}
HttpCookie GetCookieFromResponse (
string
name)
{
HttpCookieCollection cookies
=
HttpContext.Current.Response.Cookies;
int
count
=
cookies.Count;
for
(
int
i
=
0
; i
<
count; i
++
)
{
if
(String.Compare (cookies[i].Name, name,
true
)
==
0
)
return
cookies[i];
}
return
null
;
}
查看全文
相关阅读:
vscode 简介
TypeScriot 深入
TypeScript 三斜线指令
Mysql基础(二十二):表操作:创建,删除,修改,查询表
Mysql基础(十):函数(四)分组函数
Mysql基础(九):函数(三)流程控制函数(IF/CASE WHEN)
Mysql基础(七):函数(一)常见函数/单行函数分类/数学函数/日期函数/其他函数
Mysql基础(六):sql查询(六)分页查询/联合查询
Mysql基础(五):sql查询(五)子查询
Mysql基础(四):sql查询(四)连接查询
原文地址:https://www.cnblogs.com/kokoliu/p/660114.html
最新文章
java中将从数据库查询的信息输出到excel文件中
读取xlsx文件的内容输入到xls文件中
输入xls格式 输出 xls
处理xls文件
读取平台管理员xlsx文件
java中读取word文档里的内容
将Maven镜像更换为国内阿里云仓库
P3313 [SDOI2014]旅行(动态开点线段树+树链剖分)
P4103[HEOI2014]大工程 (虚树)
P1429 平面最近点对模板
热门文章
CF1009F Dominant Indices
2019浙江省赛题解
CF377B Preparing for the Contest(贪心+优先队列)
CF1399E1 Weights Division (easy version) (优先队列)
P2486 [SDOI2011]染色(树链剖分)
CF570D Tree Requests(树上启发式合并)
HDU6821 Set2(组合数+dp)
Vue 条件与循环
Vue 声明式渲染
JavaScript 插件 概览
Copyright © 2011-2022 走看看