3v4l.org

run code in 300+ PHP versions simultaneously
<?php ob_start(); $cookie_name = "mysiterandomuser"; $cookie_value = "justanotheruser"; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); ob_end_clean(); ?> <!DOCTYPE html> <html> <body> <?php if(!isset($_COOKIE[$cookie_name])) { echo "Cookie named '" . $cookie_name . "' is not set!"; } else { echo "Cookie '" . $cookie_name . "' is set!<br>"; echo "Value is: " . $_COOKIE[$cookie_name]; } ?> <p><strong>Note:</strong> You might have to reload the page to see the new value of the cookie.</p> </body> </html>
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0
<!DOCTYPE html> <html> <body> Cookie named 'mysiterandomuser' is not set! <p><strong>Note:</strong> You might have to reload the page to see the new value of the cookie.</p> </body> </html>

preferences:
74.56 ms | 402 KiB | 67 Q