Peter Marklund

Peter Marklund's Home


Rails Deployment: Looking up User ID from a Session ID

Suppose you get an exception notification and you want to know which user was browsing the site when the exception occured. The exception email has the HTTP_COOKIE header with the _session_id. Assuming you are using ActiveRecordStore and that you store the user ID in the session, you can look it up with an incantation like the following:


I keep forgetting the module path to the Session class so I thought I'd post this note. The corresponding Rails file is active_record_store.rb in ActionPack.

1 comment(s)


Peter Marklund said 2007-08-11 06:14:

Eh, ok, I just realized the session data is already in the exception email, ok :-) Maybe instantiating the session object can be useful in other situations though :-)