cancel
Showing results for 
Search instead for 
Did you mean: 

PHP & cookies

bigpumpkin
Newbie
Posts: 2
Registered: 06-08-2007

PHP & cookies

I have been unable to use set_cookie() successfully in my PHP scripts. Whenever I use it, PHP whinges about HTTP headers having already been sent. The cause of this seems to be the shebang line (#!) that F9 require us to use at the beginning of PHP scripts - presumably it's interpreted as HTML content and hence triggers the output of HTTP headers.

Is there any way around this? Or am I just being dense?
2 REPLIES
N/A

RE: PHP & cookies

I have done the same sort of thing with session variables. This requires a statement
session_start();
to be placed before anything else at the start of the php script. I thought the shebang would be a problem, but it doesn't seem to be - it seems the server swallows it and doesn't pass it to the browser.
Things you might try (but have probably thought of) there must be nothing before your set_cookie() at the top of the file (not even blank lines). The shebang starts with !# not #! (not sure if the shebang is still required for php4).
Good luck
Bob

> I have been unable to use set_cookie() successfully in my PHP scripts. Whenever I use it, PHP whinges about HTTP headers having already been sent. The cause of this seems to be the shebang line (#!) that F9 require us to use at the beginning of PHP scripts - presumably it's interpreted as HTML content and hence triggers the output of HTTP headers.
>
> Is there any way around this? Or am I just being dense?

re-create-it
Grafter
Posts: 55
Registered: 13-08-2007

RE: PHP & cookies

> I have been unable to use set_cookie() successfully in my PHP scripts. Whenever I use it, PHP whinges about HTTP headers having already been sent. The cause of this seems to be the shebang line (#!) that F9 require us to use at the beginning of PHP scripts - presumably it's interpreted as HTML content and hence triggers the output of HTTP headers.
>
> Is there any way around this? Or am I just being dense?

You are obviously aware that the shebang is causing problems as there can be no output to the browser before the cookie is set. Loose the 'shebang' and see what happens!
I have successfully set cookies on PHP/F9 without the shebang and everything worked well.