Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get previous page url in codeigniter

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.

like image 438
Nighina t t Avatar asked Jun 20 '17 05:06

Nighina t t


People also ask

Where is base url in codeigniter?

The base URL of the site can be configured in application/config/config. php file. It is URL to your CodeIgniter root.

What is URL Helper in codeigniter?

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.

How base URL is defined in codeigniter?

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.

How to get the current URL in CodeIgniter?

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.

What is HTTP_referer in CodeIgniter?

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.

What is $returnobject in CodeIgniter?

$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.

Does CodeIgniter store previously visited pages in session?

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.


1 Answers

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

like image 188
Alessandro Minoccheri Avatar answered Oct 24 '22 19:10

Alessandro Minoccheri