In a Rails controller, I can set a cookie like this:
cookies[:foo] = \"bar\"
And specify that the \"secure\" (https-only) flag be on like this:
starting with rails 3.1, according to the rails security guide, you can simply set the following in your application.rb:
application.rb
config.force_ssl = true
this forces the cookie to be sent over https only (and I assume everything else, too).