Hi, just wondering if I need to set the return url to use Yii::app->user->returnUrl, or maybe some additional configuration in main.php? When I try to access Yii::app->user->returnUrl I am given the base url. For example, http://localhost/testdrive/index.php/ with out any controller/action or variables specified.
Page 1 of 1
returnUrl question?
#2
Posted 30 October 2009 - 11:53 AM
Hey all good I didn't realize you have to set it. thought it may have been automatic. Worked with...
Yii::app()->user->setReturnUrl('controller/action');
#3
Posted 02 February 2011 - 08:42 AM
what need to be done for redirecting a user to a different page other than default page after logging in??
#4
Posted 07 February 2011 - 09:20 AM
sravani, on 02 February 2011 - 08:42 AM, said:
what need to be done for redirecting a user to a different page other than default page after logging in??
Ver:1.1.6
Hi!
Try this one:
Yii::app()->user->returnUrl=array('controller/action');Or override beforeLogin() in your CWebUser class
protected function beforeLogin(){
//here could be your condition...
$this->returnUrl=array('controller/action');
return true;
}
For example you could submit together with Login and Password - Url or Variable and use it directly or as a condition for redirecting.
if($_POST['var']=='controller/action')$this->returnUrl=array('controller/action');
OR
if($_POST['var']!=1)$this->returnUrl=array('controller/action');
Do not forget validate()
This method is good when your login form is widget. Also you could create additional properties for the widget...
#5
Posted 12 February 2011 - 10:15 PM
One last clarification is that return URL is only set when you request some page and it fails the authentication then after authentication it return backs to that page who causes failure.
If the browser is redirected to the login page and the login is successful, we may want to redirect the browser back to the page that caused the authorization failure. How do we know the URL for that page? We can get this information from the returnUrl property of the user component. We can thus do the following to perform the redirection:
If the browser is redirected to the login page and the login is successful, we may want to redirect the browser back to the page that caused the authorization failure. How do we know the URL for that page? We can get this information from the returnUrl property of the user component. We can thus do the following to perform the redirection:
Yii::app()->request->redirect(Yii::app()->user->returnUrl);
Share this topic:
Page 1 of 1

Help
This topic is locked











