What are the potential pitfalls of using GET and Cookies to transfer variables between PHP pages?

One potential pitfall of using GET and Cookies to transfer variables between PHP pages is that sensitive information can be exposed in the URL or stored on the client side, making it vulnerable to security risks such as data tampering or theft. To mitigate this risk, it is recommended to use POST method for transferring sensitive data and encrypt any sensitive information stored in cookies.

// Example of transferring variables using POST method and encrypting sensitive information in cookies
// Page 1: sending data
<form method="post" action="page2.php">
    <input type="hidden" name="username" value="john_doe">
    <input type="submit" value="Submit">
</form>

// Page 2: receiving data
$username = $_POST['username'];
setcookie('encrypted_username', encrypt($username), time() + 3600, '/');