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>
Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.21, 8.4.1 - 8.4.7
<!DOCTYPE html> <html> <head> <title>PHP Cookie Example</title> </head> <body> Your first visit. </body> </html>

preferences:
50.96 ms | 406 KiB | 5 Q