开发者

Should I use sessions or go with what I have now?

I have a classifieds website where users may insert ads.

There is a insert-ad section (PHP based).

In the insert section, firstly users enter specified data and fill in all fields of the form, then they click the "Preview Ad" and the ad is previewed. The preview page is another php page which puts all the form fields from the first 'put ad' page into hidden fields.

Then if the user is happy with the preview, he or she may click the "OK" and the ad is inserted.

Now, this method of putting form data into hidden fields before acutally inserting the ad seems 'too much'. What do you 开发者_如何学Pythonthink, should I use sessions?

I am looking for stability, not performance in this case!

Thanks and if you need more input, just let me know!


The sessions may flow from one browser window to another, i.e. this way you will force the user to use a single browser window at a time (cannot design multiple ads at once). In this case, you should stick to POST variables and not use session data.


i also agree with Tatu - if something is working now, no need to rewrite it. but if you are just starting on this: sessions are more flexible (also eliminates "Page Has Expired" errors because you can redirect, and can detect duplicate submits).

dealing with multiple windows and tabs is easy: store the form data with a unique id ($id = uniqid('', true)) and pass the id through the form. this makes it easy to add steps and is more secure - the post data can't be tampered with making validation simpler.

you can have an ajax control that previews the ad, so you wouldn't be submitting the form until it's complete, but that's up to your design.


It it isn't broken, dont fix it.


That seems fine to me. If you were to put the data into a session, then you could arguably avoid the overhead of sending it back down to the browser, but on the other hand, you'd need to deal with the possibility of multiple tabs having different ad submissions within the same session. Not particularly difficult either, but a bit more work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜