I'm using the Rails session to store a cookie_jar I get from Mechanize. This lets me call a webservice and maintain the cookies it sends back.
The class takes a session in it's constructor, so I'm passing in the Rails session. Then, when I call the service, I load the cookie_jar (if I have one) like:
agent = WWW::Mechanize.new
agent.cookie_jar = YAML.load(@session[COOKIE_JAR]) if @session.has_key? COOKIE_JAR
Once I'm done making the call, I store the cookie_jar again like:
@session[COOKIE_JAR] = agent.cookie_jar.to_yaml
While I'd love to just store the "agent", it can't be serialized (and therefore can't go in the session). Here's the funky part: if I call "session.inspect" in my classes constructor (or anytime before checking if the session has the key I'm looking for), everything works fine. Remove the call to "session.inspect" and it doesn't work anymore.
Anyone know why the Rails session behaves this way?