October 27, 200817 yr I want to make a cookie in php which does this: Displays a message when I visit the site (for example <h1>Hello!</h1>), and then I can choose if I want to display that message the next time I visit the site. Any tips for how I can make this cookie?
October 27, 200817 yr <?php if( empty( $_COOKIE['visited'] ) ) { setcookie('display', "Hello!"); setcookie('visited', true); } if( isset( $_COOKIE['visited'] ) && !empty( $_COOKIE['display'] ) ) { echo "<h1> {$_COOKIE['display']} </h1>"; } if( isset( $_POST['submit'] ) ) { setcookie('display', false); } ?> <form action="" method="post"> <input type="submit" name="submit" value="Don't display" /> </form> Something like this?
Create an account or sign in to comment