Module: Camping::Session

### Home Classes Methods

### In Files

- lib/camping/session.rb

### Methods

- ::included

### Files

- CHANGELOG
- COPYING

### Class/Module Index

Quicksearch

- Camping
- Camping::Base
- Camping::Controllers
- Camping::Cookies
- Camping::H
- Camping::Helpers
- Camping::Models
- Camping::Models::Base
- Camping::Reloader
- Camping::Server
- Camping::Server::Options
- Camping::Server::XSendfile
- Camping::Session
- Camping::Views
- Camping::X

No matching classes.

# Camping::Session

## Getting Started

To get sessions working for your application:

1. `require 'camping/session'`

2. Define a secret (and keep it secret): `set :secret, "SECRET!"`

3. Mixin the module: `include Camping::Session`

4. Throughout your application, use the `@state` var like a hash to store your application's data.

    require 'camping/session'    # 1

    module Nuts
      set :secret, "Oh yeah!"    # 2
      include Camping::Session   # 3
    end

## Other backends

Camping only ships with session-cookies. However, the `@state` variable is simply a shortcut for `@env['rack.session']`. Therefore you can also use any middleware which sets this variable:

    module Nuts
      use Rack::Session::Memcache
    end

### Public Class Methods

included(app) click to toggle source

    # File lib/camping/session.rb, line 28
    def self.included(app)
      key    = "#{app}.state".downcase
      secret = app.options[:secret] || [__FILE__, File.mtime(__FILE__)].join(":")

      app.use Rack::Session::Cookie, :key => key, :secret => secret
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.