• RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

Accessing session data using session_id

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

@user=CGI::Session::ActiveRecordStore::Session.find_by_session_id(@session_id).data[:user]

11 Responses so far.

  1. zickzackv says:

    This was the line a realy needed. Thanks so much.

  2. infrid says:

    Great stuff. Many thanks!

  3. Amit says:

    Thanks a lot mate

  4. bob says:

    zVOoYG hi nice site thx http://peace.com

  5. gauda says:

    thanks for sharing dude!

  6. Tuscon says:

    thanks for the great info

  7. Travel says:

    Thanks for sharing, i would not have enjoyed figuring this out myself.

  8. SBA says:

    Enjoyed the read, will bookmark.

  9. Andy says:

    It’s good to receive the data from a specific session id, but in my case, the current session id keeps changing because there is no cookie enabled in my browser. The session database (I set the sessions to be stored in database) is full of useless sessions since the new request will receive a new session id. Is there a way to reuse the current session id in a new request without cookie? Thnx.


Github2S3: Backup Github Repositori...

Cross Posted from http://vinsol.com/blog Who doesn't know GitHub now a days, ...

Edge Rails: Time#current...

Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now

Edge Rails: Array#random_element...

Array#rand is deprecated in favor of Array#random_element and will be ...

Edge Rails Updates...

New edge rails deprecations: Time#last_year is deprecated in favor of Time#prev_year Time#last_month ...

Download recursive directories with...

Using ftp to download multiple files using 'mget' command is ...

Edge Rails: Time#current...

Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now

Edge Rails: Array#random_element...

Array#rand is deprecated in favor of Array#random_element and will be ...

Edge Rails Updates...

New edge rails deprecations: Time#last_year is deprecated in favor of Time#prev_year Time#last_month ...

uninitialized constant ActionMailer...

Just a quick note, If you are getting "uninitialized constant ...

11 Things to Consider Before Deploy...

Cross Posted from http://vinsol.com/blog At VinSol, we have been ...