Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session object for "go to previous page"

Status
Not open for further replies.

Nogi

Technical User
Dec 10, 2004
132
BE
I have a question regarding a "back"-item i use on my asp-pages.
What it should do is load the previously opened page.

Example:

I have a page called database.asp, that contains some links.
One of the links is for example index1.asp.
A 'Back'-command on the index1.asp would load the database.asp again.

Problem:

I've tried the easy way with javascript history.back, but since the database.asp contains a password-embedded connection string to the database, each time the user wants to "go back" he gets prompted for the password.

The problem is solved when the previous page would simply be fully relaunched.

I've been told this can be done in asp with the "session object", but i don't know anything about this.

Can somebody help me out here or maybe point me in some direction?

Thanks in advance
 
I've tried the easy way with javascript history.back, but since the database.asp contains a password-embedded connection string to the database, each time the user wants to "go back" he gets prompted for the password.

so, your database.asp page first shows the login form, then submits to itself to process the 'login' ?

in which case you need to go back 2 pages not 1 - use javascript history method and 'go' to index -2

if that isn't the case, then if you only need it for this page, why not just specify the url explicitly ?

if you must use the session because it's on every page etc, then create an array and store this in a session variable.. then write a function to 'cycle' the array items so that each new page shifts the page lost down until the end of the array is reached (where you just delete the oldest entried). then you can specify serverside what page from the history a 'back' button links to.

or a simple way for current and last page only:

dim sBackLink: sBackLink = Session("lastpage")
Session("lastpage") = request.servervariables("SCRIPT_NAME")

then use sBackLink as your last link (though if my assumption about your database.asp page submitting to itself, this will not work)



A smile is worth a thousand kind words. So smile, it's easy! :-)
 
Pfew, thanks for your reply damber, but this is way over my head to be honest since i don't know a single thing about asp and it's scripting.

To answer a few of your questions:

1. There's no login whatsoever. There's a standardpage that contains an iframe. Inside that iframe the user can load several asp-pages that each display database results depending on a users request.
The database itself is password-protected. The pages that display the database results have the password embedded in their scripts, so when they connect to the database the user is not aware of any password-things at all.

Now, the pages that connect to the database, also contain links to other .asp pages, which all display lists of files.
It's on those pages that the "back"-command is required, so as to be able to go back to the database page where they came from.


2. The reason why i cannot use a URL-specific back command is, cause there is more then 1 database page from where a user could have came from.

Is there a way you could help me in writing such a script cause i don't know anything about asp-scripts myself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top