The way I see it is that your script never has a chance to set the cookie
plus you can not send headers after html, one other thing is that you have a
")" at the end of your setcookie function value so if you reformatted it
this way:
<?
setcookie("Cookievalue", "abcdefghijklmnopqrstuvwxyz0123456789",
time()+3600);
header("Location: index.php");
exit;
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
What that will do is as soon as it comes to the page it will set a cookie
and then take you to index.php. You do not need to use the full URL in the
Location. Plus I have had nothing but trouble with the setcookie function
so I just send the header setcookie instead, for example I use this code:
header("Set-Cookie: $CookieName=$CookieValue; path=/; expires=$expireDate");
Make sure expire is in this format and it'll work on all browsers:
$expireDate = gmdate("l, d-M-");
$expireDate .= gmdate("Y")+1;
$expireDate .= gmdate(" H:i:s")." GMT";
this sets the expiration date for one year.
All in all your new code would look like:
<?
$expireDate = gmdate("l, d-M-");
$expireDate .= gmdate("Y")+1;
$expireDate .= gmdate(" H:i:s")." GMT";
header("Set-Cookie: $CookieName=$CookieValue; path=/; expires=$expireDate");
header("Location: index.php");
exit;
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
> <html>
> <head>
> <?php
> header("Location:index.php");
> setcookie("Cookievalue", "abcdefghijklmnopqrstuvwxyz0123456789")
> time()+3600);
> ?>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> I get the following error.
>
> CGI Error
> The specified CGI application misbehaved by not returning a complete set
of
> HTTP headers. The headers it did return are:
>
> ... and nothing else!
>
> Where am I going wrong? I bet it's a simple answer.
>
> George P in Edinburgh
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]