Hello guys, I'm a beginner at PHP.
I have created cookie.php:
Note: There is an anchor to removeCookie.php right below the div.Code:<!DOCTYPE html> <?php if(!isset($_COOKIE['myCookie'])){ $welcome = "Hello New Guy!"; setcookie('myCookie', 1, time()*7*365); } else{ $welcome = "Welcome back!"; } ?> <html> <head> <meta charset="utf-8"> <title>Cookie.php</title> </head> <body> <div> <?php if(isset($welcome)) echo $welcome; ?> <a href="removeCookie.php">Remove Cookie</a> </div> </body> </html>
Here is the removeCookie.php:
Can anyone spot the error?Code:<?php setcookie('myCookie', 1, time() - 3600); header("location: cookie.php"); ?>



Reply With Quote




Bookmarks