If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Logout question help!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-27-09, 15:37
benz1984 benz1984 is offline
Registered User
 
Join Date: Oct 2007
Posts: 143
Exclamation Logout question help!

Hello All,

I have a logout button on my website that is coded

<INPUT id=but1 name=but1 type=button onClick="self.location.href='logout.asp'" value="Logout"


When the user clicks it it takes them to the logout page. Well, on the logout page I have

SESSION.ABANDON

in the code. However, once the user clicks the back button, it simply takes them back to the protected page. Is there coding that will prevent this from happening. Once the user logs out, I don't want them to be able to click back again and view the pages they had to be logged in to see.

I've googled this, and I can't seem to find anything that will work.
Reply With Quote
  #2 (permalink)  
Old 04-27-09, 18:38
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,002
Have a cookie to identify whether someone is authenticated and then in your session end (global.asa?) code, clear the cookie value. Ensure that on each page you check for the cookies existence.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 04-27-09, 19:27
benz1984 benz1984 is offline
Registered User
 
Join Date: Oct 2007
Posts: 143
I'm fairly new at this, so bear with me. Where would this code be inserted? Any examples of what It looks like? Thanks for your help
Reply With Quote
  #4 (permalink)  
Old 04-27-09, 19:54
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,002
Ignore what I said about cookies, you can probably get away with nothing but session variables.

Read more about them here: ASP Session object
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 04-27-09, 22:49
benz1984 benz1984 is offline
Registered User
 
Join Date: Oct 2007
Posts: 143
I really can't find anything that makes sense to me. Once the user clicks logout, I want the session to clear and if they hit the back button they cannot see the page they were logged in on without having to log in agian. My code looks like this, where would I insert code to prevent them from hitting the back button and seeing the page they were just on?

I am using front page. Thanks !!

CODE:

<%@ Language="VBScript" %>
<% Option Explicit %>


<%



If Session("username") <> "TOL" Then Response.Redirect("../login_db_nav.asp")



%>





<html>
<head>
<meta http-equiv="expires" content="0" />

<INPUT id=but1 name=but1 type=button onClick="self.location.href='logout.asp'" value="Logout"
Reply With Quote
  #6 (permalink)  
Old 04-28-09, 05:45
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,002
After successful login:
Code:
<%
  Session("username") = "gvee"
%>
On every "secure" page
Code:
<%
  If Session("username") = "" Then
    Response.Redirect("denied.asp")
  End If
%>
On log out:
Code:
<%
  Session.Abandon
  'OR
  Session.Contents.RemoveAll()
  'OR
  Session("username") = ""
%>
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On