how to redirect user to the requesting page after login

i have a groups controller and user can join groups by ajax link which links to groups/addnew

the logic is simple if user is guest then the ajax link result should redirect user to the login page or render the login and after login it should return to the page that it was on or submit the ajax request but it doesn’t do any of this can anyone tell me how it can be done

Do something like this in your ajax-response:




if (Yii::app()->request->isAjaxRequest)

{

 $redirectUrl = Yii::app()->createUrl(....);

 echo CHtml::script("location.href='$redirectUrl';");

 Yii::app()->end();

}




See Yii::app()->user->setReturnUrl(…) too.

I build the link by ajaxlink(), return the

<script type="text/javascript">

/<![CDATA[/

location.href=‘http://www.yiiframework.com’;

/]]>/

</script>

but didn’t redirect to www.yiiframework.com

how to fix it after the ajax requesting?

im also have sam problem , is there any solution?