My setcookie() isnt working, please help....

gesf

New member
To see if you're really setting the cookie, use this line at first in your script:
Code:
<?php

error_reporting(E_ALL);

?>
This way you'll be notified about every little error in your script.
 
HTTP headers (E.g.: Set-Cookie) must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
So... make sure any kind of output is being sent first of your setcookie().

Note: This happens to me sometimes - Remove all blank lines after the last php code block in your PHP files.
 
hi if you are using firefox install the LiveHttpHeaders plugin, it helps you see the REQUEST and the RESPONSE headers
there in the Response header you must see "Set-Cookie" parameter, only then would the browser be able to set the cookie
 
If i'm not wrong, in the manual there's a recomendation about its use:
Code:
<?php

$time = time() + 3600;
setcookie("aauname", $uname, $time);

?>
 
Back
Top