[Mongrel] Recommentation: Sessions and PStore

Bob Hutchison 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  
>> fields
>> and GET parameters to make it stateless.  As I've said repeatedly,  
>> "If
>> rails-core don't do it, you don't do it."  Rails-core does not do  
>> this.
>> You don't do it.
>
> This piece of advice I find a little troubling. Often you have to  
> store
> a lot of data temporarily in your application, f.ex. with multipage  
> form
> submissions. Having to store only simple types will make this much  
> more
> 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.

Cheers,
Bob

>
> Am I missing something here?
>
> -- 
> Thanks,
> - Jacob Atzen
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users

----
Bob Hutchison                  -- blogs at <http://www.recursive.ca/ 
hutch/>
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 mailing list