-[Bl@de Runner]- wrote:Hi all,
there is a rule that you have to set a cookie before you generate any html code. But what do you have to do, when at the beginning of the page you have a STYLE block, and that you later on in the page wants to set a cookie.
It then gives an error when the cookie is set, because the style block generated HTML code.
What can I do ?
Cookies
HAVE to be set before anything else is sent to the browser because the command to set the cookie is sent in the headers of the page. If you're generating a single page there should be no reason why you can't set the cookie before anything else.
It's also worth pointing out that you cannot use the cookie value on the same page immediately after you set it. This is because when you select a new page the browser sends the cookie data with it.
If you want to set a cookie AND use the cookie variable, then set the variable first, and use this variable to set the cookie and use later in the page.