I have a page that contains a form in my Yii app.
I want to allow all users to view this form, but on submission of the form, if the user is not logged in - I want to redirect him to the login page. After the user logs in, I want to continue the original form submission.
For example in this page : http://www.yiiframework.com/demos/blog/index.php/post/13/sadfasdfasdf#comments When the user clicks on "submit" he will be redirected to the login page and after login his comment will be submitted has a logged in user.
How should I do that?
The solution I used :
I followed this info to set the return URL : http://www.yiiframework.com/wiki/43/adding-login-form-to-each-page/
Before sending the guest to the login page, I save the POST info in session. Than when the user gets redirected to the original page, I check if the session contains the original POST info and if it does - I save it with the new user id