What I’m trying to accomplish is the ability to save and repeat arbitrary requests (possibly containing POST data and other nastiness). I’d like this to happen at as high a level as is feasible.
My first thought was to serialize $_SERVER, $_GET, $_POST, etc as well as Yii::app()->request and persist them using something like CWebUser->setState(). In terms of repeating the request, I was thinking of just restoring the superglobals and the request component, then calling Yii::app()->processRequest(). I’d need a bit of extra magic if I want the user to see the correct URL, but I can probably just do a redirect upfront. A problem that I can foresee with this approach is that there doesn’t seem to be an easy way to set the request component (there’s no Yii::app()->setRequest()).
A lower-level approach I’m also considering is to record the relevant request information (again, mostly just the superglobals) then making the client handle it with some clever JavaScript (something like turning the request into a <form>-based representation and then programmatically submitting it). Though this will almost certainly work, it seems hacky and requires the user to have JavaScript enabled.
My use case is a paywall. Some user actions require upgrading to a paid account, and what we want is for the user to be able to attempt the action and be prompted to upgrade, and for the original action to be performed automatically after they complete the upgrade.
Has anyone else ever tried anything like this? Do you have any advice? I’ve dug through the documentation and can’t find much that would help me out, but am I missing anything? Am I crazy for even attempting this?