setcookie session_start and head()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iwsyang
Forum Newbie
Posts: 7
Joined: Thu Jan 22, 2009 4:07 am

setcookie session_start and head()

Post by iwsyang »

people said setcookie MUST be the first line before any output,
people said sessin_start() MUST be the first line before any output,
people also said head() MUST be the first line before any output,.

If I need to use thes three function in one document, what is the order of these three lines?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: setcookie session_start and head()

Post by requinix »

They don't have to be the absolute first thing, they just have to be before you start outputting anything. As for what order you should use them it doesn't matter.

If output begins on line 100 then those three can be anywhere on lines 1 through 99.
Post Reply