Camping Sessions
Camping comes with a very simple library for managing sessions, just a handful of lines, a completely optional add-on. The Camping::Models::Session class stores the session data and the Camping::Session class is a mixin for the controllers.
To get sessions working for your application:
- require 'camping/session'
- Mixin the module: module YourApp; include Camping::Session end
- In your application's create method, add a call to Camping::Models::Session.create_schema
- Throughout your application, use the @state method like a hash to store your application's data.
If your application doesn't have a create method, please hit the Give Us a `create' Method page for an example.
A Few Notes
- The session ID is stored in a cookie. Look in @cookies.camping_sid.
- The session data is stored in the sessions table in your database.
- All mounted Camping apps using this class will use the same database table.
- However, your application's data is stored in its own hash.
- Session data is only saved if it has changed.
Return to CampingExtras
