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.
The base URL of the site can be configured in application/config/config. php file. It is URL to your CodeIgniter root.
CodeIgniter's URL helpers are groups of utility functions which will help you to call ,create and maintain url. It mainly have more than 20 helpers some of them you might be familiar with are URL, email, form etc. These are some common helper functions that generaly used in web based application for email, files, URLs.
Base URL should be absolute, including the protocol: $config['base_url'] = "http://somesite.com/somedir/"; If using the URL helper, then base_url() will output the above string.
In this article, we will explain to you how to get the current URL in Codeigniter. we can easily retrieve the current Url using the Codeigniter helper URL. so first we have to load the helper URL after then we can fetch the URL.
Returns the full URL (including segments) of the page the user was previously on. Due to security issues of blindly trusting the HTTP_REFERER system variable, CodeIgniter will store previously visited pages in the session if it’s available. This ensures that we always use a known and trusted source.
$returnObject ( boolean) – True if you would like a URI instance returned instead of a string. Returns the full URL (including segments) of the page the user was previously on. Due to security issues of blindly trusting the HTTP_REFERER system variable, CodeIgniter will store previously visited pages in the session if it’s available.
Due to security issues of blindly trusting the HTTP_REFERER system variable, CodeIgniter will store previously visited pages in the session if it’s available. This ensures that we always use a known and trusted source.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With