How to get previous page url in codeigniter
18,920
Solution 1
try this:
$this->load->library('user_agent');
if ($this->agent->is_referral())
{
$refer = $this->agent->referrer();
}
In this way you load user_agent
library, check if there is a referral url and then store It into a variable to use It after
Solution 2
It may be helpful
$url= $_SERVER['HTTP_REFERER'];
Author by
Nighina t t
Updated on July 06, 2022Comments
-
Nighina t t almost 2 years
I need privously visited page url in a variable and to find it inside a controller. is there any way to find it?please help me.By using following code redirect($this->agent->referrer());
i can redirected to the previous page .but I need this inside a variable to check.
-
M. Eriksson almost 7 yearsHave you simply tried:
$someVariable = $this->agent->referrer();
?
-
-
Sohan Arafat over 2 yearsWould you please tell me for CI4?
-
Admin over 2 yearsYour answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.