Jump to content

Does The Cookie Go Befor The Document Type?


migroo
 Share

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.

Edited by boen_robot
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...