http://www.perlmonks.org?node_id=715043

cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

I think my biggest problem here is trying to work out where I should be looking...

I'm adding a Rose::DB::Object (subclassed in RoseDbObject, say) and wrapped in a Manager class to a CGI Session object:

$self->session->param( user => RoseDbObject::Manager::userLoad($userna +me) );

This works, but when I end the CGI instance, the user param gets set to undef. So, on the next instance of this session, $self->session->param('user') doesn't exist as expected.

I'm guessing that there's some automatic cleanup running in Rose::DB::Object subclass (it probably is a bad idea to keep a Rose DB object persistent in a session, but since I was using it as read only... ;-), but nothing jumps out at me during a quick scan of the code.

Anybody got a clue as to whether

  1. Rose DB is undef'ing it (sensibly);
  2. CGI::Session is not freezing it; or
  3. I'm missing a different stupid error

Yes I'm being lazy - I don't want to try to write a standalone case outside of the app unless I have too. I guess I will if I have to, but I was hoping someone might have a hint or two as to what I'm missing first :)

Any ideas as to what I'm missing?

Replies are listed 'Best First'.
Re: Rose::DB::Object and CGI::Session
by perrin (Chancellor) on Oct 02, 2008 at 17:06 UTC
    You could ask on the Rose mailing list, but my general advice is to avoid putting objects in your session. You should keep session data as small as possible because it gets sent to and from your database and passed through Storable on every hit. If you just save a unique ID instead, it will be much smaller.
      Agreed. It's info needed on each request, but I think I can drop my new found obsession with Rose DB here and just store the needed info in a hashref in the session.