Class: Innate::Session

### Home Classes Methods

### In Files

- lib/innate/session.rb
- lib/innate/session/flash.rb

### Parent

Object

### Namespace

- CLASS Innate::Session::Flash

### Methods

- ::new
- #[]
- #[]=
- #clear
- #delete
- #fetch
- #flush
- #resid!
- #sid
- #store

### Included Modules

- Innate::Optioned

### Class/Module Index

Quicksearch

- Innate
- Innate::Action
- Innate::Adapter
- Innate::Cache
- Innate::Cache::API
- Innate::Cache::DRb
- Innate::Cache::FileBased
- Innate::Cache::Marshal
- Innate::Cache::Memory
- Innate::Cache::YAML
- Innate::Current
- Innate::Etanni
- Innate::Helper
- Innate::Helper::Aspect
- Innate::Helper::Aspect::SingletonMethods
- Innate::Helper::CGI
- Innate::Helper::Flash
- Innate::Helper::Link
- Innate::Helper::Redirect
- Innate::Helper::Render
- Innate::HelperAccess
- Innate::HelpersHelper
- Innate::LRUHash
- Innate::LogHub
- Innate::Mock
- Innate::Mock::Session
- Innate::Node
- Innate::Optioned
- Innate::Optioned::SingletonMethods
- Innate::Options
- Innate::Request
- Innate::Response
- Innate::Rewrite
- Innate::Route
- Innate::Session
- Innate::Session::Flash
- Innate::SingletonMethods
- Innate::StateAccessor
- Innate::Traited
- Innate::Trinity
- Innate::URLMap
- Innate::View
- Innate::View::ERB
- Innate::View::Etanni
- Innate::View::None
- Logger
- Logger::ColorFormatter
- Object

No matching classes.

# Innate::Session

Mostly ported from Ramaze, but behaves lazy, no session will be created if no session is used.

We keep session data in memory until flush is called, at which point it will be persisted completely into the cache, no question asked.

You may store anything in here that you may also store in the corresponding store, usually it's best to keep it to things that are safe to Marshal.

The Session instance is compatible with the specification of rack.session.

Since the Time class is used to create the cookie expiration timestamp, you will have to keep the ttl in a reasonable range. The maximum value that Time can store on a 32bit system is:

    Time.at(2147483647) # => Tue Jan 19 12:14:07 +0900 2038

The default expiration time for cookies and the session cache was reduced to a default of 30 days. This was done to be compatible with the maximum ttl of MemCache. You may increase this value if you do not use MemCache to persist your sessions.

### Attributes

cookie_set[R]
flash[R]
request[R]
response[R]

### Public Class Methods

new(request, response) click to toggle source

    # File lib/innate/session.rb, line 47
    def initialize(request, response)
      @request, @response = request, response
      @cookie_set = false
      @force_new_cookie = false
      @cache_sid = nil
      @flash = Flash.new(self)
    end

### Public Instance Methods

[](key, value = nil) click to toggle source
Alias for: fetch
[]=(key, value) click to toggle source
Alias for: store
clear() click to toggle source

    # File lib/innate/session.rb, line 71
    def clear
      cache.delete(sid)
      @cache_sid = nil
    end

delete(key) click to toggle source

    # File lib/innate/session.rb, line 67
    def delete(key)
      cache_sid.delete(key)
    end

fetch(key, value = nil) click to toggle source

    # File lib/innate/session.rb, line 62
    def fetch(key, value = nil)
      cache_sid[key]
    end

Also aliased as: []
flush(response = @response) click to toggle source

Additional interface

    # File lib/innate/session.rb, line 78
    def flush(response = @response)
      return if !@cache_sid or @cache_sid.empty?

      flash.rotate!
      cache.store(sid, cache_sid, :ttl => options.ttl)
      set_cookie(response)
    end

resid!() click to toggle source

    # File lib/innate/session.rb, line 90
    def resid!
      cache_sid
      cache.delete(sid)
      @sid = generate_sid
      @force_new_cookie = true
    end

sid() click to toggle source

    # File lib/innate/session.rb, line 86
    def sid
      @sid ||= cookie || generate_sid
    end

store(key, value) click to toggle source

Rack interface

    # File lib/innate/session.rb, line 57
    def store(key, value)
      cache_sid[key] = value
    end

Also aliased as: []=

[Validate]

Generated with the Darkfish Rdoc Generator 2.