3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Step 1: Set the cookie BEFORE any HTML output setcookie("abc", "abc_value", time() + 3600); // expires in 1 hour ?> <!DOCTYPE html> <html> <head> <title>PHP Cookie Example</title> </head> <body> <?php // Step 2: Check if cookie is set and display message if (isset($_COOKIE['abc'])) { echo "Hello, visiting again! Cookie value: " . $_COOKIE['abc']; } else { echo "Your first visit."; } ?> </body> </html>

preferences:
26.53 ms | 405 KiB | 5 Q