Cookies are small pieces of data stored in the user's browser (good for preferences like dark mode). Always set httponly: true for sensitive cookies so JavaScript cannot steal them, and samesite: 'Lax' to defend against CSRF.
Remember: setcookie() sends an HTTP header, so you must call it before echoing any HTML.