After logout, I tried to redirect for the home page. I tried to few ways, but not redirected.
class User extends BaseController
{
public function __construct()
{
helper('url');
}
for the logout function. I used three ways
redirect('/');
or
header("Location:".base_url());
or
route_to('/');
Redirect With Named Route To use named route, we have an option to use route(). //... public function addUser() { if ($this->request->getMethod() == "post") { // Save data here return redirect()->route("users"); // Calling name defined in 'as' in Routes.
“codeigniter redirect to same page” Code Answer's //The redirects functions accepts two parameters to execute the function first is 'Location Url' and second parameter allows the developer to use different HTTP commands to perform the redirect "location" or "refresh".
php class Redirect_controller extends CI_Controller { public function index() { /*Load the URL helper*/ $this->load->helper('url'); /*Redirect the user to some site*/ redirect('http://www.tutorialspoint.com'); } public function computer_graphics() { /*Load the URL helper*/ $this->load->helper('url'); redirect('http:// ...
as per CI 4
use
return redirect()->to('url');
if you are using route then use
return redirect()->route('named_route');
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