# Help with print cgi.header(

**URL:** <https://www.ruby-forum.com/t/help-with-print-cgi-header/53428>\
**Category:** Ruby\
**Created:** [February 4, 2006, 11:29pm UTC](https://www.ruby-forum.com/t/help-with-print-cgi-header/53428 "2006-02-04T23:29:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ernest\_Ellingson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/73ab20/32.png) [@Ernest\_Ellingson](https://www.ruby-forum.com/u/Ernest_Ellingson)\
**Post date:** [February 4, 2006, 11:29pm UTC](https://www.ruby-forum.com/t/help-with-print-cgi-header/53428/1 "2006-02-04T23:29:55Z")

</div>

I’m trying to set a cookie using Apache on RHFedora core3 and Ruby CGI  
I’m sending a pdf file.

The mail format looks as if there are two lines for the cookie header,  
but in reality there is only one.

Here are the headers I’m printing

cookexpires=(Time.now + (60 \* 24 \* 3600)).strftime("%a, %d-%m-%Y%H:%M:%S  
GMT")  
print cgi.header(“Content-Type” =\> mimeTypes[mimer])  
print cgi.header(“Content-Dispostion” =\> filename)  
print cgi.header(“Content-length” =\> s.length.to\_s)  
print cgi.header(“Set-Cookie” =\> “#{CGI.escape(“sample\_issue=yes;”)};  
expires=#{cookexpires}; domain=ftienergybusinesswatch”)  
print “\r\n”  
print(pdffile)  
print “\r\n”

The pdf file gets sent OK in Firefox. The pdf file opens correctly but  
no cookie shows up.

In IE I have to do it this way for the file to appear correctly and the  
cookie does show up in IE.

cookie=CGI::Cookie.new(“sample\_issue”, “yes”)  
cookie.expires=Time.now + (60 _24_3600) # 60 days  
cgi.header(“type”=\>mimeTypes[mimer],“Content-Disposition”=\>“filename=#{filename}”)  
cgi.out(“cookie”=\>cookie){pdffile}
