PHP/Cookies not working

79 views
asked Apr 14, 2012 in General by darkshark (1,500 points)
I am using PHP and I’ve set a code for cookies but they seem to have no affect at all. This is the code I am using, can someone please tell me what I’m doing wrong;

<html>
 <head>
 <title>Cool Gadjets</title>
 <?php
 $Month = 2592000 + time();
 setcookie(AboutVisit, date("F jS - g:i a"), $Month);
 ?>

1 Answer

0 like 0 dislike
answered Apr 14, 2012 by WebGuru (9,280 points)
edited Apr 14, 2012 by WebGuru
There is a problem in your code, you are sending the data to the browser before the cookie.
It should be like this:

 <?php
 $Month = 2592000 + time();
 setcookie(AboutVisit, date("F jS - g:i a"), $Month);
 ?>
 <html>
 <head>
 <title>Cool Gadjets</title>
...