I'm trying to make a logout function on codeigniter 4, and I'm realizing there is different things from v3
public function logout(){
session_start();
session_destroy();
return redirect()->to("/");
}
this is not redirecting me to my virtualhost / route its redirecting to localhost:8080/
That's because you need to set your base url in /Config/App.php
/* public $baseURL = 'http://localhost:8080/'; // <-- what is there now */
public $baseURL = 'https://www.mywebsite.com/'; // <-- change to your url
Then you can reference it
return redirect()->to(site_url()); // or
return redirect()->to("/");