Stateful Forms enhanced?
Posted 04 May 2010 - 08:11 AM
as you know one possibility to store page states is provided with Yii's stateful forms. Nevertheless it needs to have a page rendered containing a CHtml::StatefulForm. I was wondering if it could be possible to simulate Requests containing POST data for actions without attached views, that are only used for processing and redirecting somewhere else. It is possible to generate redirects setting GET Variables in the URL. How about using a library like cURL to generate a redirected site request with POST variables?
Background of this idea is, that I am currently building a form wizard based on an modified version of the CWizardBehavior supplied in topic http://www.yiiframew...-wizard-forms/. For reasons of code separation I'd like to some setup stuff in an register/onStart action that does not have any view attached. Instead this action finally redirects the user to the first 'real' wizard page and it would be very cool to have some POST variables prepared for this redirect call. But at least I think that it could be of advantage to generate redirects with POST variables setup not only for this purpose. What do you think? Possible?
Posted 04 May 2010 - 11:05 AM
Hi Mdomba, thanks for your suggestion, it seems to work this way. But on the other hand I do need the initialization value to get accessed globally and for a longer period of time, but only in the context of the wizard initialization. So I have to take care to unset it from the session right after the initialization step.
A main argument I feel it is difficult to estimate its seriousness is, that according to this IBM Tech Article (for java-driven webapps) HTTP Sessions are not thread safe. My apprehension is, that in coincidence of huge server load and delayed handling of requests (e.g. open in new tab twice) this could lead to a state, where two wizards are initialized identically. This would generate to a mixin of user input if they are both treated in parallel (e.g. to copy and paste in similiar workflows), leading to inappropriate results. With a volatile POST initialization I would evade such kind of trouble.
Is this apprehension realistic? Is the article only meaningful for java webapps? Does PHP or Yii cares for thread safety somehow? Is it possible that a CWebUser instance is accessed from different PHP Threads?
Posted 04 May 2010 - 12:27 PM
Posted 04 May 2010 - 02:44 PM
For the browser back problem... I think is't the same with the POST data...when hitting back button after some data is posted the browser asks to post again the POSTed data and you cannot go two pages back...
Again I don't understand exactly your need, but if session is not OK, you can maybe use the database to store the needed data but then you have in some way to distinguish different users...