Sha256: a2bfa9f351f4c3db3431f0ab7cd19cf9541f018ad65f6b67c62249ef755b65cd

Contents?: true

Size: 847 Bytes

Versions: 24

Compression:

Stored size: 847 Bytes

Contents

require 'sinatra'
require 'sinatra/cookies'
require 'json'
require File.join(File.dirname(__FILE__), 'webrick_patch')

class App < Sinatra::Base
  helpers Sinatra::Cookies
  set :environment, :production
  enable :dump_errors

  get('/sets_cookie') do
    cookies[:chocolatechip] = "chunky"
    redirect "/requires_cookie"
  end

  get('/requires_cookie') do
    cookie = cookies[:chocolatechip]
    unless cookie.nil? || cookie != "chunky"
      "ok"
    else
      JSON.pretty_generate(headers)
    end
  end
  
  get('/sets_multi_cookie') do
    cookies[:chocolatechip] = "chunky"
    cookies[:thinmints] = "minty"
    redirect "/requires_cookie"
  end

  get('/requires_cookie') do
    if cookies[:chocolatechip] == "chunky" && cookies[:thinmints] == "minty" 
      "ok"
    else
      JSON.pretty_generate(headers)
    end
  end
end

run App

Version data entries

24 entries across 22 versions & 2 rubygems

Version Path
excon-0.64.0 tests/rackups/redirecting_with_cookie.ru
excon-0.63.0 tests/rackups/redirecting_with_cookie.ru
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/excon-0.62.0/tests/rackups/redirecting_with_cookie.ru
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/excon-0.62.0/tests/rackups/redirecting_with_cookie.ru
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/excon-0.62.0/tests/rackups/redirecting_with_cookie.ru
excon-0.62.0 tests/rackups/redirecting_with_cookie.ru
excon-0.61.0 tests/rackups/redirecting_with_cookie.ru
excon-0.60.0 tests/rackups/redirecting_with_cookie.ru
excon-0.59.0 tests/rackups/redirecting_with_cookie.ru
excon-0.58.0 tests/rackups/redirecting_with_cookie.ru
excon-0.57.1 tests/rackups/redirecting_with_cookie.ru
excon-0.57.0 tests/rackups/redirecting_with_cookie.ru
excon-0.56.0 tests/rackups/redirecting_with_cookie.ru
excon-0.55.0 tests/rackups/redirecting_with_cookie.ru
excon-0.54.0 tests/rackups/redirecting_with_cookie.ru
excon-0.53.0 tests/rackups/redirecting_with_cookie.ru
excon-0.52.0 tests/rackups/redirecting_with_cookie.ru
excon-0.51.0 tests/rackups/redirecting_with_cookie.ru
excon-0.50.1 tests/rackups/redirecting_with_cookie.ru
excon-0.50.0 tests/rackups/redirecting_with_cookie.ru