Jump to content

Does The Cookie Go Befor The Document Type?


migroo

Recommended Posts

Does the cookie go be for the document type and the html tag or after the document type but before the html tag?Thanks.

Link to comment
Share on other sites

Neither... cookies are set either with JavaScript or by the server as an HTTP header. The exact method depends on the server side scripting language you have. In PHP for example, you have the setcookie() function.

Link to comment
Share on other sites

Okay sorry I should be more specific.I am using PHP and the setcookie() function and am trying to find out if the setcookie() function should come before the document type or not.I know it goes before the html tag.Thanks

Link to comment
Share on other sites

Okay sorry I should be more specific.I am using PHP and the setcookie() function and am trying to find out if the setcookie() function should come before the document type or not.I know it goes before the html tag.Thanks
It goes before ANY output. You mustn't have ANYTHING before you set a cookie. Not even a whitespace, let alone DTD or a tag.The reason for this is that, like I said, cookies are set as HTTP headers. And HTTP headers go before any ouput.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...