473,698 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

idsanjeev
241 New Member
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 3417
stepterr
157 New Member
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 Recognized Expert Specialist
Also make sure the page HTML caching attribute is set to no-cache.
Dec 17 '07 #3
idsanjeev
241 New Member
where i have to use above code and how can chek it html catch
Dec 24 '07 #4
jhardman
3,406 Recognized Expert Specialist
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
2836
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 saved sid and current sid.if both are equal it will display some details.that page have the logout link.when user click that link.the logout.php willwork.it generate a new sid for the same user. my problem is after logout when the user back from
6
14654
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 hits a submit button, which then takes the user to a 2nd PHP page which simply runs PHP code that checks the user's credentials from my database, and if authenticated creates a session, assigns a few session variables (including a session...
5
5670
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 can have only one session at a time.
2
1649
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 would we do this? this is how we are doing the login form ======= <authentication mode="Forms"> <forms loginUrl="/WebClient/SecurePages/logon.aspx" name="RSMNEmail" timeout="20" path="/"></forms>
1
2439
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 function that Redirects to signout.aspx. Signout.aspx invokes FormsAuthentication.Signout() when it loads. 3. Signout.aspx also has a login button that redirects to my application page (index.aspx). Because the user is no longer authenticated,...
25
3319
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, when I press back button, I get to the page that says "Page has Expired" but Firefox does not do this. I think it's something to do with sessions not properly unset or something like that but I haven't been able to figure it out. I am
1
3307
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 and when the user logs out, i would like the link changed back to "Login" without having to refresh the page. here is my login page <?php if (is_authed_user()) { print ('You are already logged in, <a href="index.php">click here</a> to...
4
3419
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(); Response.Clear(); FormsAuthentication.SignOut(); Response.Redirect("login.aspx"); }
10
4813
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 Jones, then login as David Smith the Welcome message below will show "Welcome Davey". And it will be Davey's information that is accessible - not David Smith's. So something is amiss but I don't know what. (BTW, this login script is based on the...
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9028
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.