How can cookies be effectively utilized in PHP to store user login information?

Cookies can be effectively utilized in PHP to store user login information by setting a cookie with the user's login credentials when they successfully log in. This cookie can then be checked on subsequent page loads to automatically log the user in without requiring them to re-enter their credentials.

// Set a cookie with the user's login information
setcookie("user_login", "username123", time() + 3600, "/");

// Check if the cookie is set and log the user in automatically
if(isset($_COOKIE['user_login'])){
    $username = $_COOKIE['user_login'];
    // Perform login logic here
}