What are the potential risks of setting a long lifespan for cookies in PHP?

Setting a long lifespan for cookies in PHP can pose a security risk as it increases the likelihood of unauthorized access to sensitive information stored in the cookie. To mitigate this risk, it is recommended to set a reasonable expiration time for cookies to limit the window of opportunity for potential attacks.

// Set cookie with a reasonable expiration time (e.g., 1 hour)
setcookie("user_id", $user_id, time() + 3600, "/");