How can I refresh it, the previous web page is not displayed. .

xiaoxiao2021-03-06  82

2002-10-08 08: 57: 44z

Write a member manager, when the member logs in, use the session variable to record the username so that you can access the specific page (a specific page verify the username, prohibiting member access), call the session.abandon () method when the member exits End the current user session and undo the current session object, such members can only re-login, but now there is a problem, when you click the browser back button, the previously accessible specific page can be displayed, how can you ban browser back? Or use other methods, when the user exits, click the back button and cannot return to the previously accessed page. . . I tried the following, and the retreat display web pages have expired, but after clicking refresh, can still be displayed

<%

Response.buffer = TRUE

Response.expires = 0

Response.cachecontrol = "no-cache"

%>

Reply to: AwaySrain (Absolute Zero) (New Year, New Start) () Reputation: 155 2002-10-08 09: 06: 00Z Score: 0

Check the session, if there is no login, go to the landing page

IF session

......

Else

......

TOP

Reply: Abigfrog (Millennium Elf) (★ java ★) () Reputation: 155 2002-10-08 09: 07: 23Z score: 20

The back button of the browser allows us to easily return the previously visited page, which is undoubtedly useful. But sometimes we have to close this function,

Prevent users from chaos the predetermined page access order. This article describes the various browser-free button schemes found on the network to analyze their respective advantages and disadvantages and appropriate

Use occasion.

I. Overview

There have been many people asking, "How can I" disable the back button of the 'browser? ", Or" how to prevent the user from clicking the back button to return to the previous photo

Overview page? "In the ASP Forum, this question is also one of the most questions. Unfortunately, the answer is very simple: we can't disable the back of the browser.

Button.

At first I feel unbelievable for someone who wants to disable the browser. Later, I saw that there were so many people who want to disable this back.

Button, I will relieve (if you want to disable only the back button, do not include the browser's forward button). Because the user can submit the form by default

After the return button returns to the table page (instead of using the Edit button!), Then edit again and submit the table one-way database into the new record. This is we don't

May it see.

So I decided to figure out how to avoid this. I have visited many websites, referring to various implementation methods described by these websites. If you

Regular access to the ASP programming website, some of this content you may have already seen. The task of this article is to introduce all possible methods to everyone, then find

Out of the best way!

Second, prohibiting caching

In many scenarios I found, there is a suggestion to prohibit page caches. Specifically, the server-side script is used as shown below:

<%

Response.buffer = TRUE

Response.expiresabsolute = now () - 1

Response.expires = 0

Response.cachecontrol = "no-cache"

%>

This method is very effective! It forces the browser to re-access the server download page instead of reading the page from the cache. When using this method, the programmer's master

To task is to create a session-level variable, determine if the user still views the page that is not suitable for passing the back button. Since the browser no longer caches this page, the browser will re-download the page when the user clicks the back button. At this time, the program can check that the session variable is to see if

The user should be allowed to open this page.

For example, suppose we have the following form:

<%

Response.buffer = TRUE

Response.expiresabsolute = now () - 1

Response.expires = 0

Response.cachecontrol = "no-cache"

IF LEN ("FirstTIMETOPAGE")> 0 THEN

& Single; Users have accessed the current page and now returns to access again.

& Single; Clear the session variable to redirect the user to the login page.

Session ("firsttimetopage" = ""

Response.Redirect "/ bar.asp"

Response.end

END IF

& Single; If the program is run here, the user can view the current page

& Single; You start to create a form

%>

We check if the user is the first time to access the current page with a session variable firstttimetopage. If it is not the first time (ie session

("Firsttimetopage") contains a value), then we clear the value of the session variable and reallite the user to a start page. In this way, when the form

When submit (at this point SompePage.ASP is opened), we must give the firstTIMETOPAGE a value. That is, we need to add the following in SomePage.asp.

Code:

Session ("FirstTimetopage" = "no"

In this way, users who have already opened somepage.asp If you click the back button, the browser will re-request the server download page, the server checks to the session

("FirstTIMETOPAGE") contains a value, then clear the session ("FirstTIMETOPAGE") and redirects the user to other pages. Of course, all

All of this requires the user to enable cookies, otherwise the conversation variable will be invalid. (For more descriptions about this problem, see for session variables

TO WORK, MUST THE Web Visitor HAVE COOKIES ENABED?)

In addition, we can also use the client code to make your browser no longer cache the web page:

If you use the above method to force your browser to no longer caching the web page, you must pay attention to the following points:

The browser cache page is only prevented when "Pragma: No-Cache" is used when using a secure connection. For pages that are not protected, "Pragma: no-cache"

It is considered to be the same as "Expires: -1", and this time the browser is still cached, but the page is marked as an immediate expiration.

In IE 4 or 5, the "Cache-Control" Meta Http-Equiv flag will be ignored and does not work.

In practical applications, we can add all of these code. However, since this method cannot be applied to all browsers, it is not recommended. but

If it is in an intranet environment, administrators can control which browser that users use, I think someone will use this method.

Third, other methods

Next, the method we have to discuss will be refund the button itself in the back button, not the browser cache. There is an article here. ReWiring the Back Button is very

It is worth reference. But I noticed that if you use this method, although the user caught the back button when the user clicks on the back button, he won't see the page previously entering the data, but just click

It can be two times, this is not the effect of our hopes, because many times, stubborn users can always find ways to circumvent prevention measures.

Another way to disable the back button is to open a window without the toolbar with the client JavaScript, which makes it difficult for users to return to the previous page, but

Not impossible. A more secure but quite annoying method is to open a new window when the form is submitted, and at the same time close the window where the form is located. But I feel

This method is not worth careful, because we can't open a new window every time you submit a form.

So, can we join the JavaScript code in that we don't want users to return? JavaScript code added in this page

The effect used to generate a clicking forward button, which offsets the action generated by the user to click the back button. JavaScript code for implementing this function is as follows

Down: