Skip to content

Instantly share code, notes, and snippets.

@levelfour
Created June 24, 2014 04:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levelfour/5d60e17c46de5658f68d to your computer and use it in GitHub Desktop.
Save levelfour/5d60e17c46de5658f68d to your computer and use it in GitHub Desktop.
Sinatra basic sample using session
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'sinatra'
configure do
use Rack::Session::Cookie
end
get '/foo' do
session[:msg] = "Hello, world"
end
get '/bar' do
"Session #{session[:msg]}"
end
# sinatraをCGIで起動
set :run, false
set :environment, :cgi
Rack::Handler::CGI.run Sinatra::Application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment