Forum Moderators: coopster

Message Too Old, No Replies

help with php cookies

php cookies

         

BaderBlog

6:26 pm on Sep 15, 2009 (gmt 0)

10+ Year Member



Hello

I am trying to build a php script, i need a way to store the cookie inside client browser to prevent him dublicating form entry.

so if the cookie still exist, the user will have a message tell him " you cannot do it again untill, one entry perday"

if the user doesn't have cookie, then set a cookie for him/her.

look what i have done

<?php
if (isset($_cookie['user']))
{ echo "you cannot do it again untill, one entry perday";
}
else
{
setcookie("user","bader",time()+86400);
}
?>

i put it at the top of my page, but i got this erorr

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\d\step1.php:1) in C:\AppServ\www\d\step1.php on line 8.

where is the problem please ?

jatar_k

6:51 pm on Sep 15, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld BaderBlog,

that means that there is output, possibly a blank line in the file before your opening <?php tag

BaderBlog

7:38 pm on Sep 15, 2009 (gmt 0)

10+ Year Member



but i really got nothing before it .. how should i fix this !

eelixduppy

9:12 pm on Sep 15, 2009 (gmt 0)



Make sure you aren't outputting anything in an include file, also, before you try to modify the headers. This is a common mistake when dealing with this type or error.