Jump to content

Cookies or Sessions?


AdRock

Recommended Posts

I have a form on my website which is a contact form.

 

I have validation where if a filed is blank an error message is displayed but I have nothing to store what data has been entered so when the user has to go back and fill in the blank field, all the other data has beeen erased.

 

I am trying to find out the best way to store the data temporarily until the user has entered all fields before clicking the submit button.

 

What would be the best way to do this........cookies or sessions?

Link to comment
https://forums.phpfreaks.com/topic/38841-cookies-or-sessions/
Share on other sites

neither, why, because if there are errors you should return the form refilled in with the data that didn't have errors. You don't need a session or a cookie to do that, if your form processing logic is self contained, (IE: using the same script as the form process segment of your application). Cookies and sessions are great, but there is a time when and when not to use them, because you can't control them if the user restricts you, that's why sessions is best for a login controlled application. Sure you can do what you want, but for a trivial form process, the error control should be script based!

 

 

printf

Link to comment
https://forums.phpfreaks.com/topic/38841-cookies-or-sessions/#findComment-186769
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.