I'm currently struggling with finding a way to extract a segment from the referrer URL using CodeIgniter.
As for normal url segment can be found by
$this->uri->segment(n)
where n is the number of section we are looking for.
My intuition says I should use the following, but of course it's not working.
$this->agent->referrer()->segment(1);
Can someone help me out?
The referrer function in Codeigniter doesn't allow for a segment - it simply returns the $_SERVER
parameter (Found in User_agent.php):
public function referrer()
{
return empty($_SERVER['HTTP_REFERER']) ? '' : trim($_SERVER['HTTP_REFERER']);
}
You will therefore need to explode the URL or use http://php.net/manual/en/function.parse-url.php to get the elements for you.