zoukankan
html css js c++ java
FormsAuthentication最简单的使用
登录
protected
void
btnLogin_Click(
object
sender, EventArgs e)
{
string
userName
=
"
UserName
"
;
string
password
=
"
Password
"
;
if
(txtUserName.Text
==
userName
&&
txtPassword.Text
==
password)
{
setValidTime(chkRememberMe.Checked, userName);
Response.Write(
"
<script>top.location='Default.htm';</script>
"
);
}
else
{
labMsg.Text
=
"
登录失败,请重试
"
;
}
}
/**/
///
<summary>
///
设置有效时间
///
</summary>
protected
void
setValidTime(
bool
RememberMe,
string
strUserName)
{
if
(RememberMe)
{
FormsAuthentication.SetAuthCookie(strUserName,
true
);
HttpCookie lcookie
=
Context.Response.Cookies[FormsAuthentication.FormsCookieName];
lcookie.Expires
=
DateTime.Now.AddYears(
1
);
}
else
{
FormsAuthentication.SetAuthCookie(strUserName,
false
);
}
}
注销
protected
void
btnSignOut_Click(
object
sender, EventArgs e)
{
FormsAuthentication.SignOut();
}
查看全文
相关阅读:
内部类&匿名内部类
Object:
多 态★★★★★(面向对象特征之三)
接 口:
继 承(面向对象特征之二)
封 装(面向对象特征之一)
三:面向对象:★★★★★
Codeforces 719 E. Sasha and Array (线段树+矩阵运算)
uestc oj 1218 Pick The Sticks (01背包变形)
uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)
原文地址:https://www.cnblogs.com/yvesliao/p/889058.html
最新文章
牛客练习赛71 B-烙印 (几何)
Frogs HDU
Rebuild-HDU
数学推导- 圆上任取3个点构成三角形
P3455 [POI2007]ZAP-Queries (莫比乌斯反演
杭电多校 hdu6627 equation
2019杭电多校6 hdu6638 Snowy Smile(二维最大矩阵和 线段树)
Codefoeces-242E XOR on Segment
SPOJ
主席树 第k大板子
热门文章
HDU
2019 xtcpc C.Chika and Friendly Pairs
边权树剖板子
HDU
Hdu-1533 Going Home(最小费用最大流)
Codeforces Round #300
2018 hncpc 部分题
多线程
Java-包
异 常
Copyright © 2011-2022 走看看