I a web application that I am developing (being developed in PHP) when a user posts any request for service the user has to fill in a very length form.

Once user fills in the form and submits it another page (confirmation page) is loaded in which all values filled in by user are show. I must point out that at this stage the data is not saved to MySQL yet. Now on this page the user can either save the service request or go back. 

My problem starts here. When the user goes back. All data filled in is lost. BTW User tend to use Browsers Back button instead of the back button provided on the confirmation page.

How can is persist data filled in by user so that user can edit/make changes to data and again submit changed data.


Question: Persistent session cookies: remember session even after closing the browser
Answer: Hi you could use javascript for this. 

Using these 3 functions. 
its properly the best way and then you wont have problems if your are using Varnish

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i &lt; ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}