When we add the closing tag at the end of a block of php code some problems with the headers and cookies, this happends because a newline is added directly after the closing tag (?>).
The solution is omit the closing tag at the end, this is perfectly legal.
