Login and continue

November 7, 2003 by Carl Grint

I have recently developed a system that enabled the forms to be 'saved' as 'draft' and the user could re-login and complete the details as required.

Instead of using Cookies it basically inserted the data into the database, and provided a history section for them to via and choose to continue, which was just an update page with the details they had already filled in compelted, and they finished the remainder of the form.

The database table contained a recordid which was called when the user click the 'draft' form link and the update page dynamically pulled in the details.
Obviously the 'history' list was based on their usedid, which is created with dreamweaver when you use the login script anyway.

Creating a Cookie/Session for the form, as it was over 3 pages was simply done using the information for the Person (UserID) and the Record (recordID) passed through the URL and created on either the first page, or in my instance in a non graphic ASP page which created the Sessions Session("name") = Request.Querystring("name"), then a redirect to the first page.

If I can be of any further assistance, please do contact me tutorials@cgwebdevelopment.co.uk

Do also check out the Tutorials section on my site (www.cgwebdevelopment.co.uk/tutorials) there is a Tutorial request form.

Saving user data in cookies

December 10, 2003 by Robert Kara

Hi Vikki,

how's things, good I hope?

Here's what I thought might be the best practical solution to your situation.

Please ensure that you do the following though:

1) For every page that contains a form that you wish for the user to fill in you would need to put the following ASP code at the top of the page, and ensure that the "Action=" property of the form calls the same page (i.e itself).

<%
Dim saveIndicator

saveIndicator=FALSE
If Request.ServerVariables("Request_Method") = "POST" Then
 Response.Cookies("var1") = Request.Form("var1")
 Response.Cookies("var2") = Request.Form("var2")
 Response.Cookies("var3") = Request.Form("var3") 'etc
 Response.Cookies("var1").Expires = Date()+3650 'Remember them for 10 years
 Response.Cookies("var2").Expires = Date()+3650 'Remember them for 10 years
 Response.Cookies("var3").Expires = Date()+3650 'Remember them for 10 years
 saveIndicator=TRUE
End If
%>

2) As you might have already guessed from the code above, all we are simply doing is posting the form back to itself and checking the "Request_Method" server variable to see if our form has been submitted. If so, then we simply write to our cookies associating the name of the cookie with the value in the form field. Easy eh! The saveIndicator variable is something that I would use to output some HTML to the user giving them feedback that their information has been saved.  This is not necessary but it's always nice to give the user visual feedback whenever they do something.

3) But how do get the stuff back?

Easy answer: we use ASP's Request method, i.e. Request.Cookies("var1").  But in order to create some sort of control, you would probably have a page that loads when they log back in to the site presenting them with a list of what forms still needing to be completed.

My suggestion is to cycle through the cookies collection to create references back to those incomplete pages like so:

<%
Dim cookie
Dim form1Complete, form2Complete, form3Complete 'etc
Dim var1, var2, var3 'etc

form1Complete=FALSE
form2Complete=FALSE
form3Complete=FALSE
var1=FALSE
var2=FALSE
var3=FALSE

For Each cookie in Request.Cookies
 Select Case cookie
  Case "var1"
   var1=TRUE
  Case "var2"
   var2=TRUE
  Case "var3"
   var3=TRUE
  'etc
   End Select
Next

If var1 AND var2 AND var3 Then
 form1Complete=TRUE
End If
'etc
%>

All failing conditons would have HTML links back to those pages.

I hope this satisfies your query Vikki, as I have just realised that I was caught up in a moment, a moment that lasted for 2 hours. Reply back if you to me if you have any trouble understanding some of the stuff. :-)