[Rails] Sessid.

Fernando Lujan
2006-05-08T17:46:53Z

Jeremy Kemper wrote:
> On May 8, 2006, at 10:09 AM, Fernando Lujan wrote:
>> I want something like this...
>>
>> In my app.
>>
>> session[:user_id] = "15"
>> session[:group_id] = "18"
>>
>> This will generate a session. I will store it in a database, and
>> later on I want to restore it. Without cookies and so forth.
>>
>> Later, I want something like restoring a session.
>>
>> @id = ID OF THE PREVIOUS CREATED SESSION.
>> @session = Session.find(:first, :conditions=> ["sessid =
?", @id])
>> @session[:user_id] #returns the user id of the session
>>
>> I know that the session data attribute is marshaled. How can I
>> restore it?
>
> You don''t need any of these mechanics - session load/save is
> automatic.  Just use session directly and forget about it.
>
> When you do session[:user_id] = foo, the session is created if not
> present, updated with :user_id => foo.  When the action is complete,
> the session is serialized and stored for you.  On next page load,
> session is reconstituted according to the value of cookie OR query
> parameter _session_id.

Hum, the problem is that I''m not loading the session in a page. I will
load it in another app. I''m integrating rails with a old system...
Because of that, I need to retrieve the values previously stored in the
session. To use in the app.

Because I can store it in the database, I thought that will be easy to
restore the values. Is it possible?