3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php ob_start(); $cookie_name = "mysiterandomuser"; $cookie_value = "justanotheruser"; setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); ob_end_clean(); ob_flush(); ?> <!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>
based on duvHa
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
Notice: ob_flush(): failed to flush buffer. No buffer to flush in /in/79egp on line 7 <!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>
Output for hhvm-3.15.4 - 3.17.3
Notice: failed to flush buffer. No buffer to flush in /in/79egp on line 7 <!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>
Output for hhvm-3.12.14
<!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>