user34537
user34537

Reputation:

How do i make form data not disappear after hitting refresh?

I went to test my page on another browser. On google chrome i can fill out a form, hit back and forward and still have the data there. Now i need to refresh the page so certain data is correct (such as session id if the cookie expires or user logs out before submitting). I refresh and lose all data. Is there some option i can set so all data is kept?

Upvotes: 2

Views: 3059

Answers (3)

Vidar Vestnes
Vidar Vestnes

Reputation: 42984

Yes, the only secure way to do this is to use a serverside script to store the form temporarly. Since browsers handles back/forward diffrently your page won't be x-browser compatible if you don't use the server. If the user hits the back button you are kind of lost already since no post is done, unless you post the form with some javascript magic before the new page is refreshed.

Upvotes: 1

Jamie
Jamie

Reputation: 613

What framework are you using? For example, ASP.Net WebForms would handle this via ViewState (yuck), ASP.Net MVC would require you to do this manually etc.

You essentially need to persist your data somewhere while the page reloads, and then re-populate the controls.

Upvotes: 1

Lars Mæhlum
Lars Mæhlum

Reputation: 6102

You would have to send the values to the server while they are typed in, and then repopulate the form fields on refresh.

Upvotes: 1

Related Questions