473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

logout page don't allow to go back with out login

idsanjeev
241 100+
sir i am creating a page for logout but problems is here if user is logout and click on standard back button then go on previous page so how can restricted it if user is logout then you don't go back without login
Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <html>
  4. <head>
  5. <meta http-equiv="Expires" content="here goes the present date" />
  6. <title>Voice Of Baraunians</title>
  7. <!--#include file="front.inc"-->
  8. </head>
  9. <body>
  10. <%If Request.Cookies("userid") = "" Then%>
  11.   <div style="Position:Absolute; top:150; left:250;background-color: #f0f0f0">
  12.     <center><h2><font face="arial" color='blue'>You are not authorised to view this page. You will be prosecuted for this action</font></h2></center>
  13.   </div>
  14. <%Else%>
  15.   <div style="Position:Absolute; top:150; left:100">
  16.     <h2>Logging Out ............</h2>
  17.     <h4>Wait a moment.</h4>
  18.   </div>
  19. <%
  20.   Dim conn
  21.   Dim R
  22.   Dim vuserid
  23.   Set conn = Server.CreateObject("ADODB.Connection")
  24.   conn.Mode = adModeReadWrite
  25.   conn.Open("DSN=Oracle; USER ID = STARTER; PASSWORD = STARTER")
  26.   Set R = Server.CreateObject("ADODB.Recordset")
  27.   R.Open "Select Userid, status from userid", conn, adOpenStatic, adLockOptimistic, adCmdText
  28.   vuserid = Request.Cookies("userid")
  29.   R.Find "userid = '" & vuserid & "'"
  30.   If Not R.EOF Then
  31.     R("Status") = 0
  32.     R.Update
  33.   End If
  34.   Response.Cookies("userid") = ""
  35.   R.Close
  36.   Set R = Nothing
  37.   conn.close
  38.   Set Conn = Nothing
  39.   Response.Redirect "login.asp"
  40. End If
  41. %>
  42. </body>
  43. </html>
  44.  
Dec 15 '07 #1
4 3400
stepterr
157 100+
When the user logs off you need to set the cookie to expire sometime in the past so that it is removed. You could do something like this.

Expand|Select|Wrap|Line Numbers
  1. HttpCookie c1 = Request.Cookies[admin.COOKIE_USER];
  2. HttpCookie c2 = Request.Cookies[admin.COOKIE_PSWD];
  3. Request.Cookies.Remove(admin.COOKIE_USER);
  4. Request.Cookies.Remove(admin.COOKIE_PSWD);
  5. c1.Expires = DateTime.Now.AddDays(-10);
  6. c2.Expires = DateTime.Now.AddDays(-10);
  7. c1.Value = null;
  8. c2.Value = null;
  9. Response.SetCookie(c1);
  10. Response.SetCookie(c2);
Dec 15 '07 #2
jhardman
3,406 Expert 2GB
Also make sure the page HTML caching attribute is set to no-cache.
Dec 17 '07 #3
idsanjeev
241 100+
where i have to use above code and how can chek it html catch
Dec 24 '07 #4
jhardman
3,406 Expert 2GB
where i have to use above code and how can chek it html catch
you need to set all the cookies at the very beginning of the page, before you start sending any HTML code to the browser.

As for caching (this word is actually French. "cache" is the correct spelling, not "catch") check in the HTML forum, I don't remember the code off-hand.

Jared
Dec 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sujeevan | last post by:
Hi, i have created a web. in the 1st page. user can login.after login i start the session and save it in his db-record. also the page give a link to my important page. in that page i check the...
6
by: Jeff | last post by:
I've searched the web for hours trying to figure out this problem and can't seem to find any pertinent answers. I have a website where the user starts on a login page, puts in their credentials and...
5
by: vincent | last post by:
Hi, If i login to the site again (may be in the same pc or different pc), system must allow me in and end my previous session. How do i go about doing this? This is to ensure that an user...
2
by: Brian Henry | last post by:
We have our windows forms login set up and working good, well it works at least, just now we need a logout button, so when you click on it, the user will be logged out of the authentication, how...
1
by: MichaelR | last post by:
I have an asp.net application using forms authentication. 1. It has a simple login page (login.aspx) that uses FormsAuthentication.RedirectFromLoginPage(. . . ). 2. My application has a logout...
25
by: crescent_au | last post by:
Hi all, I've written a login/logout code. It does what it's supposed to do but the problem is when I logout and press browser's back button (in Firefox), I get to the last login page. In IE,...
1
by: Adrock952 | last post by:
I have a link on my site which obviously says "Login" where users log in. I would like that link to be changed to "Logout" when the user has successfully logged in and the session has been created...
4
by: shahidrasul | last post by:
hi in my project when i click on logout anchor it goes to logout page and my code in logout page is if (Session != null) { Session = null; Session.Abandon(); ...
10
by: DavidPr | last post by:
When I logout as one user and log in under a different user, it opens with the last user's information. User 1 - Unsername: Davey Jones User 2 - Unsername: David Smith I log out from Davey...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.