-
asp 로그인 & 로그아웃asp 2010. 4. 20. 20:59
쿠키 이용
login.asp------------------------------------------
<form name="login" method="post" action="main.asp">
<input type="text" name="id" size="10"><br>
<input type="password" name="passwd" size="10"><br>
<input type="submit" value="login">
</form>
main.asp------------------------------------------
<%
If response.cookies("loginCheck").haskeys Then
response.write request.cookies("loginCheck")("id") & "님이 로그인 하셨습니다."
else
id = request.Form("id")
passwd = request.Form("passwd")If id = "lsb" And passwd = "1111" Then
response.write id & "님이 로그인 하셨습니다."
response.write "<a href='logout.asp'>[logout]</a>"
response.cookies("loginCheck")("id") = id
Else
response.redirect("login.asp")
End if
End if%>
logout.asp------------------------------------------
<%
response.cookies("loginCheck").Expires = Date -1
response.redirect("login.asp")
%>세션사용
<%
If session.contents("id")<>"" Then
response.write session.contents("id") & "님이 로그인 하셨습니다."
else
id = request.Form("id")
passwd = request.Form("passwd")If id = "lsb" And passwd = "1111" Then
response.write id & "님이 로그인 하셨습니다."
response.write "<a href='logout.asp'>[logout]</a>"
session.contents("id") = id
Else
response.redirect("login.asp")
End if
End if%>
<%
session.abandon
response.redirect("login.asp")
%>[출처] asp 로그인 로그아웃|작성자 toqoo