![]() |
|
||
| | 首页 | 下载中心 | 高手学院 | 视频教程 | 书籍教程 | 模板中心 | 空间评测 | 每日代理 | 站长服务 | 高手论坛 | | |||
![]() |
|||
|
||||||
| 使用getauthcookie改进认证cookie 作者:佚名 文章来源:不详 点击数: 更新时间:2005-5-23 | ||||||
![]() ![]() |
||||||
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <authentication mode="Forms"> <forms name="AuthCookie" loginUrl="login.aspx"> <credentials passwordFormat="Clear"> <user name="swords" password="est"/> </credentials> </forms> </authentication> <customErrors mode="Off" /> <globalization requestEncoding="gb2312" responseEncoding="gb2312" /> </system.web> </configuration> login.aspx <%@page language="vb"%> <script runat="server"> sub login(obj as object,e as eventargs) if FormsAuthentication.authenticate(tbusername.text,tbpassword.text) then dim cookie as httpcookie cookie=Formsauthentication.getauthcookie("swords",false) cookie.expires=datetime.now.addminutes(2) response.cookies.add(cookie) 'FormsAuthentication.setAuthCookie(tbusername.text,false) lblmessage.text="success!" else lblmessage.text="invalid!" end if end sub </script> <html><body> <form runat="server"> <asp:label id="lblmessage" runat="server"/> <asp:textbox id="tbusername" runat="server" /> <asp:textbox id="tbpassword" textmode="password" runat="server" /> <asp:button id="submit" runat="server" onclick="login" text="submit"/> </form> </body></html> ps: FormsAuthentication.signout注销用户的cookie setAuthCookie(tbusername.text,false) false关闭浏览器自动失效,true关闭浏览器依然有效. |
| |
| 文章录入:FOX 责任编辑:FOX 【发表评论】【告诉好友】【打印此文】【关闭窗口】 | |
|
| | 设为首页 | 加入收藏 | 联系我们 | 合作伙伴 | 友情链接 | 广告投放 | 关于我们 | | ||
![]() |
|
|