codeigniter 4 redirect to home 1

codeigniter 4 redirect to home

//You can use redirect in codeigniter by loading helper 'url'
$this->load->helper('url');

//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".
if (!$user_logged_in)
{
  redirect('/account/login', 'refresh');
}

Here is what the above code is Doing:
1. Loads the URL helper
2. Checks to see if the user is logged in
3. If the user is not logged in, redirects them to the login page

Similar Posts