Logout Script

G

Guest

Hey guys, I followed the Article number 825498, which tells me how to create
a password-protected Web Page.

I was able to create it and get it to work on my local machine. However,
I'm trying to figure out and understand how to create a log out button.

Can you help.
Thanks.
Terry
 
M

MD Websunlimited

Hi Harddrive747,

You have to abandon the session using session.abandon.

<form action=thispage.asp post >
<input type="submit" value="logout" name="action" >
</form>

<%
if request.servervariables("REQUEST_METHOD") = "POST" then
if request.form("action") = "logout" then
session.abandon
request.redirect "logout.asp"
end if
end if

================
 
G

Guest

Mike thanks for the information, however, I got another problem with this. I
had to make one change on the form to make sure it would post. So I did that
and everything seems to work fine, except for the redirect.

Here is the error message I get when I try to use this

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Redirect'
/Updates/SelActivity.asp, line 56

So I will change where the form action goes to and see what happens.

Thanks for your help.
 
T

Thomas A. Rowe

Try using:

Response.Redirect "logout.asp"

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
G

Guest

Hey, Ive already tried this,
however i'm still logged-in when
i go back to default.asp
+++++++++++
 
G

Guest

This is what i have in my passwordprotect.asp as i thought this is where i
wanted the logout button. And it links directly to logout.asp. However, when
i am at logout.asp and went back to default.asp i am still logged in. Thank
You for your help guys :D

++++

<% @language="vbscript" %>
<!--#include virtual="/51260/_private/51260.inc"-->
<html>
<head><title>Password-Protected Page</title></head>
<body>
<h3>Password-Protected Page</h3>
<p>You are logged on as:
<%
If Len(Session("UID")) = 0 Then
Response.Write "<b>You are not logged on.</b>"
Else
Response.Write "<b>" & Session("UID") & "</b>"
End If
%>

<form action=logout.asp post >
<input type="submit" value="logout" name="action" >
</form>

<%
if request.servervariables("REQUEST_METHOD") = "POST" then
if request.form("action") = "logout" then
session.abandon
Response.Redirect "logout.asp"
end if
end if

%>

<p><a href="default.asp">Back to default</a></p>

</body>
</html>
++++++++++++++++++++++++++++++++++++
 
T

Thomas A. Rowe

Just create a text or image link to logout.asp from whatever page you want.

The only content (no html tags, etc.) in your logout.asp page is the following:

<%
session.abandon
Response.Redirect "login.asp"
%>

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top