[Mongrel] Recommentation: Sessions and PStore
hutch at recursive.ca
Mon Sep 4 11:33:31 EDT 2006
On Sep 4, 2006, at 11:02 AM, Jacob Atzen wrote:
> On Sun, Sep 03, 2006 at 09:18:06AM -0700, Zed Shaw wrote:
>> 2) DON'T STORE COMPLEX OBJECTS IN THE SESSION!
>> This especially goes for you Java people who think the session
>> store is
>> a temporary database. The session really only works for simple types
>> like integers, strings, etc. You *must* follow the mantra of "Share
>> Nothing" and either store everything in the database or use form
>> and GET parameters to make it stateless. As I've said repeatedly,
>> rails-core don't do it, you don't do it." Rails-core does not do
>> You don't do it.
> This piece of advice I find a little troubling. Often you have to
> a lot of data temporarily in your application, f.ex. with multipage
> submissions. Having to store only simple types will make this much
> complicated compared to simply storing a single object in the session
> which is repeatedly updated until stored in the database.
> Is the data in the session not simply marshalled and then read back on
> the next request? If so, what is the difference between simple and
> complex types, they should marshal and unmarshal equally well, yes?
This is true of all webapp servers I've ever used that serialises/
restores sessions. The source of trouble I've encountered is where
there is some sort of object identity that the application is
assuming. This can be very subtle. "Share nothing" is one solution,
the other is to rely on some mechanism (say the DB, or in my case,
xampl) to manage this for you. (If you are thinking of storing what
amounts to structured data, then you are probably okay, except that
this inevitably evolves into something else and you'll end up trying
to debug a nasty situation and you'll be looking at the change that
did it and that'll be nowhere near where the problem actually is.)
I'm sure there are other problems, and they'll be subtle too.
> Am I missing something here?
> - Jacob Atzen
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
Bob Hutchison -- blogs at <http://www.recursive.ca/
Recursive Design Inc. -- <http://www.recursive.ca/>
Raconteur -- <http://www.raconteur.info/>
xampl for Ruby -- <http://rubyforge.org/projects/xampl/>
More information about the Mongrel-users