A cookie problem. I hope you can help me. thank you. where is the error? PHPcode & lt ;? Phpif (empty ($ _ COOKIE [lastVisit]) {if it is empty, it is the first time you log on to echo & quot;. Hello, this is the first time you log on! & Quot; record the problem of setcooki cookie at the first logon time. I hope you can help me. thank you. where is the error?
PHP code
Error:
Hello, this is your first login!
Warning: Cannot modify header information-headers already sent by (output started at D: \ LAMP \ AppServ \ www \ cookie \ lastVisit. php: 4) in D: \ LAMP \ AppServ \ www \ cookie \ lastVisit. php on line 6
------ Solution --------------------
So change the code... In addition, if it is a UTF-8 encoded document, do not have a B header.
PHP code
$ First = FALSE; if (empty ($ _ COOKIE ['lastvisit']) {$ first = TRUE; setcookie ("lastVisit ", date ('Y-m-d H: I: s'), time () + 30*24*3600);} else {$ first = FALSE; setcookie ("lastVisit", date ('Y-m-d H: I: s'), time () + 30*24*3600);} if ($ first) {echo "Hello, this is your first logon! ";}Else {echo" your last access time was ". $ _ COOKIE ['lastvisit'];}
------ Solution --------------------
If there is output before the header, enable the buffer ob_start ();