Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14120 reviews 1680 hosting providers

Questions & Answers

PHP/Cookies not working

Apr 15, 2012 by darkshark
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 votes
Apr 15, 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>