How can the use of header() function in PHP help in redirecting users to a different page after performing a logout action?
To redirect users to a different page after performing a logout action in PHP, you can use the header() function to send a raw HTTP header to the browser, which will redirect the user to the desired page. This function should be called before any output is sent to the browser to avoid any errors.
<?php
// Perform logout action
// Redirect to a different page
header("Location: index.php");
exit();
?>