Setting cookies from a library?

I thought it would be nice if my login code handled session and cookie
management in a Session class, rather than explicitly in the controller.
So I made the session class attach itself to the current session:

module Hark
  class Session

    def self.get(session, cookiejar)
      session[:hark_session] ||=

    def initialize(cookiejar)
      @cookiejar = cookiejar

Then I call it from my login action:

class HarkController < ApplicationController
  def login

      hs = Hark::Session.get(session, cookies)

This works beautifully in unit tests, but when I try to run it in webrick,
I get an error when it tries to serialize the session; apparently, the
CookieJar contains an anonymous class.

Is there some way I can allow my session class to get/set cookies without
passing it the CookieJar each time? On the face of it, I'd need to store a
"pointer" to the CookieJar#[] and CookieJar#[]= functions, without storing
the cookiejar itself. But that's not very Rubyish. Ideas?

Jay Levitt