Search code examples
htmlautosave

To Autosave HTML form data - Is using HTML5 localstorage a better option?


I have a form which has many fields to get input from the user. I need to implement Autosave functionality for this form, In the beginning I thought I will do it using PHP, AJAX. But after a small research I found out that we can use HTML5 localstorage object for the same purpose in which we dont have to use the server at all.

I believe HTML5 option will be a better option in terms of performance, but will that be better enough in security aspect as well.

Or is there any other option I need to consider, before starting the real work.

Thanks in advance for any input on this.


Solution

  • In my opinion, localstorage is a much better option for autosave than PHP & AJAX.

    With the latter, you have to make AJAX requests (both to save the data, as well as to check if there is autosaved data when the page loads), as well as use up disk space to store the autosaved data.

    With localstorage, the data is in the client's browser, which means there's no load on your server at all.

    From a security aspect, in either case you want to make sure you don't autosave things like credit card or SSN numbers.