baking rails 1.2.6 cookies and sessions

Hi,

Is there documentation on how to use CookieStore for sessions in rails 1.2.6 ?

I have added this to environment.rb, but it’s not working.

config.action_controller.session_store = {
:session_key => ‘_yummy_session’,
:secret => ‘seakret’
}

Is there anything else I need to do?

Thu Feb 07 04:28:16 -0500 2008 (25051) You have a nil object when you didn't expect it! The error occurred while evaluating nil.restore /usr/lib/ruby/1.8/cgi/session.rb:304:in `[]' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/cgi_process.rb:127:in `session' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/cgi_process.rb:155:in `stale_session_check!' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/cgi_process.rb:110:in `session' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1052:in `assign_shortcuts_without_flash' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/flash.rb:140:in `assign_shortcuts' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:424:in `process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in `process_without_session_management_support' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in `process' /usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/rails.rb:76:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/rails.rb:74:in `synchronize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/rails.rb:74:in `process' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:155:in `process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:154:in `each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:154:in `process_client' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:281:in `initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:281:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:264:in `initialize' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:264:in `new' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel.rb:264:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/configurator.rb:282:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/configurator.rb:281:in `each' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/configurator.rb:281:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:128:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/../lib/mongrel/command.rb:212:in `run' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.1/bin/mongrel_rails:281 /usr/bin/mongrel_rails:19:in `load' /usr/bin/mongrel_rails:19

Thanks,
Mikey

You need to upgrade to Rails 2 which has the cookie store :slight_smile:

jeremy

Seriously, I am wondering how to make cookie store work with rails 1.2x
I cannot upgrade to 2.0.2.

Hi,

Is there documentation on how to use CookieStore for sessions in
rails 1.2.6 ?

I have added this to environment.rb, but it's not working.

  config.action_controller.session_store = {
    :session_key => '_yummy_session',
    :secret => 'seakret'
  }

Is there anything else I need to do?

Well at a bare minimum you'll need to lift the cookie_store.rb from
rails 2.0 and add it to your local copy of rails (if you've frozen
your gems into vendor then you can do this without messing with your
other rails apps. You'll also have to modify session_management.rb to
load cookie store, and hope that the interface that session stores
present hasn't changed much between 1.2 and 2.0

Fred

Hi,

Is there documentation on how to use CookieStore for sessions in

rails 1.2.6 ?

I have added this to environment.rb, but it’s not working.

config.action_controller.session_store = {

:session_key => '_yummy_session',
:secret      => 'seakret'

}

Is there anything else I need to do?

Well at a bare minimum you’ll need to lift the cookie_store.rb from

rails 2.0 and add it to your local copy of rails (if you’ve frozen

your gems into vendor then you can do this without messing with your

other rails apps. You’ll also have to modify session_management.rb to

load cookie store, and hope that the interface that session stores

present hasn’t changed much between 1.2 and 2.0

Oh. I got this splendid idea from reading Obie Fernandez’s book “The Rails Way”
In it he says that if you want to use CookieStore with Rails 1.2x you need to use the above line.

I guess the book is incorrect, if what you say is true.