How to get previous page url in codeigniter?
In this post we will give you information about How to get previous page url in codeigniter?. Hear we will give you detail about How to get previous page url in codeigniter?And how to use it also give you demo for it if it is necessary.
Today, i will tech you how to redirect previous page url in codeigniter php. we may sometime require to redirect previous page after login then you can get previous page path by using codeigniter user_agent library, request array or using session.
here, i will show you both example to getting previous page url so, you can simply redirect on that page in codeigniter 3 application.
first we will see user_agent library using referrer() for getting previous page url.
Example 1:
$this->load->library('user_agent');
if ($this->agent->is_referral()){
print_r($this->agent->referrer());
}
Example 2:
print_r($_SERVER['HTTP_REFERER']);
Example 3:
Controller method, using session:
$this->session->set_userdata('previous_url', current_url());
Getting in Controller method:
$previous_url = $this->session->userdata('previous_url');
print_r($previous_url);
I hope it can help you….
Hope this code and post will helped you for implement How to get previous page url in codeigniter?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs