On Wed, 20 Jan 2010 13:19:03 +0000, a...@ashleysheridan.co.uk (Ashley Sheridan) 
wrote:

>On Wed, 2010-01-20 at 15:45 +1100, clanc...@cybec.com.au wrote:
>
>> On Tue, 19 Jan 2010 22:45:14 -0500, phps...@gmail.com (Phpster) wrote:
>> 
>> >The first setcookie call is empty which produces the errors that cause  
>> >the second cookie to fail.
>> 
>> I'm afraid not. I modified the program started to read:
>> 
>> <?php //;V;;;                                Cypalda/Index.php   Printed: 
>> 21/3/09
>> 
>> session_start ();
>> 
>> setcookie ('Try_1', 'Works', time()+3600);
>> echo '&nbsp;';
>> setcookie ('Try_2', 'Doesnt', time()+3600);
>> 
>> With the result
>> 
>> Warning: Cannot modify header information - headers already sent by (output 
>> started at
>> D:\Websites\cypalda.com\index.php:6) in D:\Websites\cypalda.com\index.php on 
>> line 7
>> 
>> And cookie 'Try_2' is not set.
>> 
>> I suspect you have been running with output buffering on, but I had left it 
>> in the default
>> state, which is off.
>> 
>> 
>
>
>Well the problem here is obvious, you just changed the line that was
>causing the error to another line that causes another error! Why do you
>need to echo a space character? Remove that line and you will get rid of
>this new error.

When you are working with sessions, provided you start your program with 
session_id(), you
can then do anything you like with session variables at any point in your 
program. In my
original question I asked if there was a cookie equivalent. 

Someone said there was, but the above is simply demonstrating that their 
suggested
solution doesn't work. It appears there is no solution, but that the workaround 
is to turn
on output buffering, at least until you finish setting cookies, so that you can 
be certain
that no output is generated before this point.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to