Rails configuration for sessions

I’m trying to get the configuration done for sessions but I can’t seem
to find any documentation on how to do it beyond the merest of basics.

I would rather have something that would NOT persist a marshalled object
to the database since that’s just not something I want to do. I want to
be able to read the data for one.

But there’s really nothing to identify how that is done.
Or even identified in the Rails::Configuration because:
– it’s missing from the installation (no docs?)
– there’s nothing via the internet that I can find which actually
specifies session configuration. This does not:
http://glu.ttono.us/articles/2006/05/22/configuring-rails-environments-the-cheat-sheet

And I can’t find anything that that really discusses how to get
configurations done.

Hello Tom.
Stupid question, or observation more to the point, but,
http://wiki.rubyonrails.org/rails/pages/HowtoChangeSessionOptions
where its always lived :wink: *

Regards
Stef

(* yes yes, I know that the wiki went through and is still kinda going
through a re-juggle but… you get the point :wink:

Tom A. wrote:

I’m trying to get the configuration done for sessions but I can’t seem
to find any documentation on how to do it beyond the merest of basics.

I would rather have something that would NOT persist a marshalled object
to the database since that’s just not something I want to do. I want to
be able to read the data for one.

But there’s really nothing to identify how that is done.
Or even identified in the Rails::Configuration because:
– it’s missing from the installation (no docs?)
– there’s nothing via the internet that I can find which actually
specifies session configuration. This does not:
http://glu.ttono.us/articles/2006/05/22/configuring-rails-environments-the-cheat-sheet

And I can’t find anything that that really discusses how to get
configurations done.

Any of the currently available authentication generators & engines
should provide you with the foundation for all this information.

You don’t have to store the entire User object in the session data, I
dont, especially since some of that data might not be useful or secure
inside a session.

Typically I just store the user_id, security_token, and token_expiry.

And the session hash works just like anyother has in rail, params for
instance.

Thanks. I’ve gone through that and found that I can easily change the
storage to a database, but it’s always a marshalled object.

What I’m trying to learn/find is how to store session data in a NON
marshalled object, which was the point of my original post. I’m sorry
if I didn’t make that clear. However, the initial page here certainly
doesn’t address it and the closest thing I can find is:

How else would you store something like a session without serializing
it in some way? Just curious what you are thinking.

Chris

Hello Tom,
So, to clarify, what your getting at/asking for is a way to store an
arbitrary complex data structure such as a session without having it
marshalled, so that each field is stored as an int, numeric, varchar
etc, as appropiate ? Two ways spring to mind in that case.

The first way -I- can think of doing that is to create an database

table (say) mySession and corresponding model, and then populate it in
much the same way as every other object. If you think about it (and
assuming I have the cut o’ your jib here) then this has problems
(needing to make sure that you know your session ‘fields’ ahead of time,
no adding in ‘one more field’ to the session ;). This would have to be
keyed by (say) session id in the application.rb but… should be do-able.

If your -not- tied to storing sessions in the database (no pun

intended for perl programmers :wink: then you could try overloading/writing
your own session/session_store methods so that they spit out YAML to the
tmp directory instead of a marshalled object. I think that may be a gain
actually hrms oh well, yes :slight_smile:

Of course, these are only theories at the present, feel free to

scream and tell me why they wouldn’t work or perhaps someone else here
already has.

I must admit, I -personally- don't like the whole 'blobs' in my

database, but, thats jst me. Let me know if you need any more
thoughts/help/code.
Regards
Stef

Stef T wrote:

assuming I have the cut o’ your jib here) then this has problems
(needing to make sure that you know your session ‘fields’ ahead of time,
no adding in ‘one more field’ to the session ;). This would have to be
keyed by (say) session id in the application.rb but… should be do-able.

I think this is the direction to pursue. I think BLOBs are a horrible
idea in databases unless you can guarantee they will only in in
existence for a short period and can be easily reconstructed. Easily
also means without inconvenience…

I’ll see what I can come up with on my adventures.
Thanks.

Stef T wrote:

Hello Tom.
Stupid question, or observation more to the point, but,
http://wiki.rubyonrails.org/rails/pages/HowtoChangeSessionOptions
where its always lived :wink: *

Thanks. I’ve gone through that and found that I can easily change the
storage to a database, but it’s always a marshalled object.

What I’m trying to learn/find is how to store session data in a NON
marshalled object, which was the point of my original post. I’m sorry
if I didn’t make that clear. However, the initial page here certainly
doesn’t address it and the closest thing I can find is:

http://weblog.textdrive.com/article/196/on-rails-sessions

which still misses the mark.