Hello Ben,
<?php
echo "<a href="index.php?".session_name()."=".session_id()."">test</a>\n";
setcookie(session_name(), session_id(), time()+3600);
?>
Warning: Cannot modify header information - headers already sent by (output started at /home/ben2/public_html/sessiontest2.php:5) in /home/ben2/public_html/sessiontest2.php on line 9
what you see is the effect of how PHP works: Pretty straightforward. First, you generate an output to the client using the echo statement. Then you attempt to set a cookie, which requires certain HTTP headers. But these headers cannot be set any more, because *content* has already been sent. What your are trying to do is like writing the address on an envelope after you dropped it into the mailbox.
Don't really know what to do now - maybe someone knows.
You have two options - IMHO a good one and a bad one.
The good one: Rearrange the order of your instructions, so that anything that has to do with HTTP headers comes first. Then, only after all headers have been sent by your script, start outputting contents.
The bad solution: Use output buffering. That is likely to work the way you wish, but it leaves the scrambled sequence in your source code unaffected.
So long,
Martin
Schildkröten können mehr über den Weg berichten als Hasen.