huge junk mail wrote:

Can someone tell me why I can't have

$_SESSION['foo'] = 'content of foo';

following by


Someone from told me that it can confuse
browser ( But, still I
can't the idea why it can happen. Does register
session means sending a 'header: location' too?

You can, and you should not get any errors from PHP. The reason someone suggested that this can confuse the browser is as follows:

1. When you initiate a session, PHP tells Apache to send a Set-Cookie header (assuming you are using the default session settings).
2. When you manually set a Location header, the HTTP response status code changes from 200 OK to 302 Moved Temporarily.

So, at least in the past, some Web browsers would ignore Set-Cookie headers that are sent in a response that basically says, "Hey, that thing you are looking for is over here now." Also, in some scripting languages (I believe in PHP as well, but I am not positive), the Set-Cookie headers would not even be included when you changed the status code like this, so it didn't matter what the browser thought.

I have found that this problem appears to be fading fast, and I have recently used this combination without any user complaints (yet). :-)

What problem are you experiencing?


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to