(If anyone else wants to mention how they use sessions I'm curious)

> 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.

Right, yes that's cool.  It's just a bit concerning when you try to store
objects in a backing store..., string stuff is a-okay because it's small.  I
would probably push forward in a form for this instance probably, but that's
just an implementation detail.

> 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.

Well, putting it in a form requires no overhead for your system.  This seems to
not constitute "more permanent data".  As far as specific information related
to the user, you bet there's a better place to store it :-), in a database with
real fields.  See..., a session doesn't allow incremental data lookups, or
incremental changes.  You dump the whole thing in memory, and then manipulate
it on the perl level.  Not to mention if you change one aspect of the session,
you trigger now a complete update of that field.  Maybe you're working on a
site that doesn't have anything related to "more permanent data"..., like
userid's and that sort of thing.  I somehow thought you were trying to store
the users preference of currency in the session as an object to use to convert
further stuff, or something like that.  (Haven't used that module in
particular, so I was just making a wild guess)

> 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.

Well obviously :-), it's there for a good reason... it makes our lives as site
programmers a lot easier.  I use sessions, but am really careful about how I
use them, I usually just put stuff in a session that will be used on 80% of
pages.  Normally it turns out that I only insert/modify the session on
login, and try to keep subsequent updates to a minimum.  (Cost to benefit
analysis, the session can save you a lot of sql queries, or it can add a lot) 
I'm working on sites right now that have very specific needs in terms of
performance, but everyones needs are different. 

Thanks,
Shane.

Reply via email to