Changeset 225 for trunk/lib/camping/session.rb
- Timestamp:
- 09/26/2007 03:52:10 (14 months ago)
- Files:
-
- 1 modified
-
trunk/lib/camping/session.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/camping/session.rb
r205 r225 12 12 # For a basic tutorial, see the *Getting Started* section of the Camping::Session module. 13 13 require 'camping' 14 require 'camping/db' 14 15 15 16 module Camping::Models … … 18 19 class Session < Base 19 20 serialize :ivars 21 # SQL injection to bypass id field checks 22 set_primary_key '"="" OR "' 23 20 24 def []=(k, v) # :nodoc: 21 25 self.ivars[k] = v … … 39 43 # If none is found, generates a new session. 40 44 def self.persist cookies 45 session = nil 41 46 if cookies.camping_sid 42 47 session = Camping::Models::Session.find_by_hashid cookies.camping_sid … … 64 69 ActiveRecord::Schema.define do 65 70 create_table :sessions, :force => true, :id => false do |t| 66 t.column :hashid, :string, :limit => 32 71 t.column :hashid, :string, :limit => 32, :null => false 67 72 t.column :created_at, :datetime 68 73 t.column :ivars, :text 69 74 end 75 add_index :sessions, [:hashid], :unique => true 70 76 end 71 77 reset_column_information … … 109 115 @state = (session[app] ||= Camping::H[]) 110 116 hash_before = Marshal.dump(@state).hash 111 s = super(*a) 117 return super(*a) 118 ensure 112 119 if session 113 120 hash_after = Marshal.dump(@state).hash … … 117 124 end 118 125 end 119 s120 126 end 121 127 end
