First off, I'm doing this becuase I need to store variables (in
currency) that are generated on a per-user session, for a short period of
time (3 to 5 requests). I'm using a database back-end for the session.
I was initially wrong in my thinking about Math::Currency, and my solution
was to "stringify" the instance, so I only store "$10.45" instead of a
Math::Currency object.
Where do you put your "more permanent" data, and what constitutes "more
permanent" data? I can't think of anything that would be faster/easier to
store and retrieve specific information related to that user or session.
I'd agree that the session needs to be handled carefully, but I think the
careful part is not leaving stuff in the session that doesn't need to be
there, instead of not using it.
Jay
On Mon, 19 Jun 2000, Shane Nay wrote:
> Okay, backup a second..., you're doing this... why? Do you need a
> Math::Currency object stored inside the session?..., that could be quite a
> hefty object. See, everything you write to a session you have to read back in,
> and any time you update any small part of it it has to re-write the whole
> record. What storage mechanism are you using for sessions, Filestore,
> Database? Generally I think it's a best practice to be careful about what
> you're stuff in your sessions, i.e. how much data you're putting in there. A
> complete update of several objects could be pretty hairy since you have to do a
> complete re-write of that record whenever you change one small detail. You
> also have to read in that entire session, and decompose it which could take a
> little while. Basically you're adding quite a bit of overhead to your
> web-application. Personally I like to keep my sessions really small, and put
> more permanent data elsewhere, does anyone else have a "best practices" sort of
> thing on what should/should not be stored in a session? (This seems to come up
> almost weekly I think)
>
> Thanks,
> Shane.
> (Also you should read up on freeze thaw, because they can't store _everything_)
>
> On Mon, 19 Jun 2000, you wrote:
> > Hello,
> > I'm trying to use Math::currency with sessions, and I've run into a
> > stumper. I initialize variables and make them Math::Currency objects, and
> > display them just fine, but when I come back (unthaw the session) instead
> > of seeing the value I get the reference showing
> > "Math::Currency=HASH(0x86b022)" instead of the value as it showed the
> > first time through.
> >
> > It's a reference going in, and a reference coming out, but for some reason
> > it doesn't like being stuck into Apache::Session.
> >
> > I can work around it by testing if it's a Math::Currency reference, and
> > call Math::Currency->new. But this seems a little silly. Anyone seen
> > this before?
> >
> > Jay Jacobs
>