Cookies

Important: These docs are for the outdated Jets 5 versions and below. For the latest Jets docs: docs.rubyonjets.com

You can set cookies with the cookies helper. Example:

class PostsController < ApplicationController
  def index
    cookies[:favorite] = "chocolate"
    render json: {message: "yummy cookies set"}
  end

  def show
    cookies.merge! 'foo' => 'bar', 'bar' => 'baz'
    cookies.keep_if { |key, value| key.start_with? 'b' }
    puts "cookies.size: #{cookies.size}"
    render json: {message: "cookies behave like a hash"}
  end
end