Monday, January 17, 2011

Accessing session data using session_id

This is the very rare case but some times we need to access the data stored in ActiveRecordStore through session_id(specially when the request is not coming from browser). Here is a way I found and like to share:

@user_id = ActiveRecord::SessionStore::Session.
find_by_session_id('<session_id>').data[:user_id]

No comments:

Post a Comment