in reply to Re: Sending a cookie header and HTML output
in thread Sending a cookie header and HTML output

Just thought of another problem: say I'm authenticating a user, I check for a cookie containing a session ID, if the cookie doesn't exist I check for login parameters from a form. If the login is valid, I want to set a cookie containing a session ID. I have all the preceeding in a subroutine which I call, then later I will print out an HTML document (say: a welcome message) - which is the best way to handle this? Should I send the cookie & header, let the script finish running then send the HTML (the actual data, not the header), or should I return the cookie to the calling code and send it only right before the HTML? Thanks.

  • Comment on Re: Re: Sending a cookie header and HTML output

Replies are listed 'Best First'.
Re: Re: Re: Sending a cookie header and HTML output
by tcf22 (Priest) on Jun 24, 2003 at 15:01 UTC
    I prefer to send all of my output(including the headers) at the end of the script, after all of the processing has been done. The reason I do it that was is because if an error occurs during processing, you don't have an half loaded page, then an error. I can just scrap all of the legitiment output and display the error message.