in reply to Re^2: Cookies write to screen, not to cookie file
in thread Cookies write to screen, not to cookie file

As chromatic says, you need to display the form as one Web page, then submit it to a script that will output the cookie headers. That script will need to parse the information the user entered, then output the headers (including the cookie headers), then output the body of the Web page.

As for line endings in the headers, they are important, though whether you should use "\n" or "\r\n" may be Web server dependent (I usually use "\n", and assume my Web server will change it to a protocol-appropriate line ending). Line endings are how the Web server and browser know that one header has ended and the next has begun.