<?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>
You have javascript disabled. You will not be able to edit any code.