title: How does the CGI cookie work in Ruby?
body: <p>This is the example I keep seeing online as how to set cookies.  </p>
  
  <pre><code>require "cgi"
  cookie = CGI::Cookie.new("rubyweb", "CustID=123", "Part=ABC");
  cgi = CGI.new("html3")
  cgi.out( "cookie" =&gt; [cookie] ){
    cgi.html{
      "\nHTML content here"
    }
  }
  </code></pre>
  
  <p>I tried doing it this way and it sets the cookie and then comes up with a blank page.</p>
  
  <pre><code>#!/usr/local/bin/ruby
  
  require 'cgi'
  load 'inc_game.cgi'
  cgi = CGI.new
  
  cookie = CGI::Cookie.new("rubyweb", "CustID=123", "Part=ABC");
  cgi.out( "cookie" =&gt; [cookie] ){""}     
  
  #see if game submit buttons pressed
  doIt = cgi['play']
  puts "Content-type: text/html\n\n"  
  
  play = Game.new
  
  #welcome
  if doIt == ''
  puts play.displayGreeting
  end
  
  #choose weapon
  play.playGame
  
  if doIt == 'Play'
      move = cgi['weapon']
      human = play.humanMove(move)
      computer = play.ComputerMove
      print human
      print computer
      result = play.results(human,computer)
      play.displayResults(result)
  end
  </code></pre>
  
  <p>So my question first would be, what am I missing/doing wrong?  Secondly I am wondering if anyone would want to explain what .out does as opposed to .header or if there is a difference?</p>
  
  <p>Thanks,</p>
  
  <p>Levi</p>