<%=Session.SessionId%> 是單獨生成的唯一ID標識,可刷新調試。 |
<%Session.TimeOut=10%> |
<% '是提取url中變量loginout的值是否為true,若為真,就執行Session.Abandon()。 if Request.QueryString("loginout")="true" then Session.Abandon() end if '只有在當點擊了submit按鈕的前提下,再來判斷提取的東西都不為空,則建立Session對象。 submitname=request.form("submit1") if submitname="submit" then if Request.Form("name")<>"" and Request.Form("pwd")<>"" then Session("name")=Request.Form("name") Session("pw")=Request.Form("pwd") end if end if %> <% '如果Session("name")不為空,則顯示Session("name")的值,并且做一個到info.asp的鏈接。 if Session("name")<>"" then response.write("你的name值是:"&Session("name")) response.write("<br><a href='info.asp'>顯示你的資料</a>") else '否則,即Session("name")為空不存在,則顯示表單用以輸入建立Session的平臺。 %> <form action="login.asp" method="post"> 姓名:<input type="text" name="name"><br> 密碼:<input type="password" name="pwd"><br> <input type="submit" value="submit" name="submit1"> </form> <!--同樣做了一個到info.asp的鏈接。--> <a href="info.asp">顯示你的資料</a> <%end if%> |
<% '如果session對象值為空則跳轉到login.asp if session("name")="" then Response.Redirect("login.asp") '否則就顯示個人信息 else Response.Write("你的姓名:"&session("name")&"<br>") Response.Write("你的密碼:"&session("pw")&"<br>") end if %> <a href="login.asp">返回</a> <a href="login.asp?loginout=true">退出</a> |
<SCRIPT RUNAT=Server Language=VBScript> ....... Sub Session_OnStart ....... End Sub ....... </SCRIPT> |
<SCRIPT RUNAT=Server Language=VBScript> ....... Sub Session_OnEnd ....... End Sub ....... </SCRIPT> |
<%if session("num") < 2 then%> <body onunload=javascript:window.open("bug.asp")> <%session("num")=session("num")+1%> <%else%> <script> self.close() </script> <%end if%> |
新聞熱點
疑難解答