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
;
}
查看全文
相关阅读:
pyhton 小技巧
scikit-learn K近邻法类库使用小结
机器学习加速方法
Virtual box安装回退的一系列可能的原因及解决办法
Linux 定时任务
Redis 操作命令
在linux下安装并运行scrapyd
同步/异步 异步回调 协成 线程队列
Python常用的标准库以及第三方库有哪些?
Flask 知识点
原文地址:https://www.cnblogs.com/kokoliu/p/660114.html
最新文章
【转】使用EF CodeFirst 同时访问MySql和SqlServer配置
安卓安装APP提示无签名问题
魅蓝手机安装APP失败问题
查看Tomcat注意事项
layer.js打印iframe方法
【MySQL】mysql中any,in,some,all的区别
@SuppressWarnings注解用法
yum安装docker报错(今天玩docker出现的错误)
IDEA修改git账号及密码的方法
SpringBoot+Maven多模块项目(创建、依赖、打包可执行jar包部署测试)完整流程
热门文章
request的getAttribute()和getParameter()的区别
@RequestMapping用法详解(以及路径问题)
什么时候用forward? 什么时候用redirect?
idea 2017怎么设置黑色或白色背景
基于Spring Boot的问答系统之一:elasticsearch 7.2的hello world入门
自然语言处理 01
python 小技巧
python 小技巧 np.nan
集成学习的调参数
python 小技巧
Copyright © 2011-2022 走看看