I am using Yii
and the problem i am getting is with the Yii::app()->user->returnUrl
.It always returns me to the index.php
page.
How can I set its value to the page which requested the current page as I do not know from which page user has visited the current page?
I created a Yii extension to manage return URLs, you can find it here: https://github.com/cornernote/yii-return-url#yii-returnurl
It's an improvement over the way Yii handles it because it stores the return url in the GET/POST data instead of the SESSION. This means that if you have multiple tabs open then each can have it's own return url.
There is no such thing as:
Yii::app()->user->urlReferrer
It should be:
Yii::app()->request->urlReferrer
orYii::app()->request->requestUri (current page)
So try this:
Or this one (which I personally prefer):
For those using Yii2
You can use like this
Hope this will help you
You can use
Yii::app()->request->urlReferrer
to see where the user came from.Be careful, if the user came from a 3rd party site, then this will redirect them away from your site.
You can also do like that