Confirmation Page and [Back] button

D

Dennis Allen

Hi. On my online ordering form I use browser cookies to keep track of
users items. My confirmation page reads:

"If any of this information is incorrect, please go back to the order
form and change it. We thank you for your patronage.".

Question. At what point will I be able to delete my cookies? If I
delete them before posting the online form, then they won't be available
if customers [go back] from the confirmation page.

In the confirmation page, I was thinking maybe a <body
onunload="del_cookie()">. I tried it, but it didn't seem to work. Does
the [Back] button activate onunload?
 
T

Trevor L.

Dennis,
You could add an expiry date/time to the cookie.

This function will create a cookie with an expiry time of a specified number
of days and/or hours :
function createCookie(name, value, days, hours)
{
if (days || hours)
{
var newhours = (days) ? days*24 : 0
newhours += (hours) ? hours : 0

var date = new Date()
date.setTime(date.getTime() + (newhours*60*60*1000))
var expires = date.toGMTString()
}
else {var expires = ""}

document.cookie = name + "=" + value + "; expires=" + expires + "; path=/"
}
You could in fact create a cookie with a unique name based on date and time.
If the expiry is one day, that should be long enough, or possibly even one
hour with a warning to the user that they have one hour to finish.

The function to delete a cookie is
function eraseCookie(name)
{ createCookie(name, "", -1) }
(It sets the expiry to -1 day, i.e. it is no longer valid.)

I don't know "Does the [Back] button activate onunload?" On way to find out
is put an alert onunload and see whether the Back button activates the
alert.
 
T

Thomas A. Rowe

The body onunload would activate whenever a user is leaving the page.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top