Rails sessions

Discussion in 'Ruby' started by Bauduin Raphael, Jul 27, 2004.

  1. Hi,

    I wondered how sessions are stored in rails, and if it can be tailored.

    I'm a cgikit user as everyone knows by now ;-) and I like the way how
    this is abstracted: you can write your own session storing class and
    tell your app to use it. Is this possible (or something similar) with
    Rails? I looked at the doc but only saw a reference to a drb session
    daemon. (did I miss the right place in the doc?)

    The reason I'm interested in such a thing is that I thought (but I
    didn't test it yet) that it would let me integrate cgikit (and possibly
    rails) developments in an existing PHP application eg.

    thanks.

    Raph
     
    Bauduin Raphael, Jul 27, 2004
    #1
    1. Advertising

  2. Bauduin Raphael wrote:

    > Hi,


    Moin!

    > I wondered how sessions are stored in rails, and if it can be tailored.


    As far as I know CGI::Session is used for this.

    > I'm a cgikit user as everyone knows by now ;-) and I like the way how
    > this is abstracted: you can write your own session storing class and
    > tell your app to use it. Is this possible (or something similar) with
    > Rails? I looked at the doc but only saw a reference to a drb session
    > daemon. (did I miss the right place in the doc?)


    Have a look at cgi/session.rb in your ruby library directory -- there
    should be two sample session types in there already. (FileStore and
    MemoryStore)

    > thanks.
    > Raph


    Regards,
    Florian Gross
     
    Florian Gross, Jul 27, 2004
    #2
    1. Advertising

  3. > I'm a cgikit user as everyone knows by now ;-) and I like the way how
    > this is abstracted: you can write your own session storing class and
    > tell your app to use it. Is this possible (or something similar) with
    > Rails? I looked at the doc but only saw a reference to a drb session
    > daemon. (did I miss the right place in the doc?)


    Rails uses CGI::Session and will take any store for that. By default it
    uses the PStore, which is a file-based store that uses Marshal to allow
    all kinds of objects in it. It's very easy to use and scale, but
    unfortunately it's also quite slow. In some benchmarks I did, it was
    responsible for a 50% speed decrease over other methods, such as the
    MemoryStore.

    You can specify another Store than the default in the dispatcher. Have
    a look at vendor/railties/dispatcher.rb.

    On that note, does anyone have a database store for CGI::Session? It
    would be nice to ship that with Rails as an option.
    --
    David Heinemeier Hansson,
    http://www.rubyonrails.org/ -- Web-application framework for Ruby
    http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
    http://www.basecamphq.com/ -- Web-based Project Management
    http://www.loudthinking.com/ -- Broadcasting Brain
    http://www.nextangle.com/ -- Development & Consulting Services
     
    David Heinemeier Hansson, Jul 27, 2004
    #3
  4. Bauduin Raphael

    Tim Bates Guest

    David Heinemeier Hansson wrote:
    > On that note, does anyone have a database store for CGI::Session? It
    > would be nice to ship that with Rails as an option.


    I already told you I'd send you my CGI::Session::ActiveRecordStore. See
    off-list.

    Tim.

    --
    Tim Bates
     
    Tim Bates, Jul 28, 2004
    #4
  5. I'd like to see a Drb-based store, so that you could have the speed of
    memory-based access along with the ability to have a dedicated session
    server for seamless failover of webservers behind a hardware load
    balancer.

    Carl

    On Wed, 28 Jul 2004 08:21:55 +0900, Tim Bates <> wrote:
    > David Heinemeier Hansson wrote:
    > > On that note, does anyone have a database store for CGI::Session? It
    > > would be nice to ship that with Rails as an option.

    >
    > I already told you I'd send you my CGI::Session::ActiveRecordStore. See
    > off-list.
    >
    > Tim.
    >
    > --
    > Tim Bates
    >
    >
    >
     
    Carl Youngblood, Jul 28, 2004
    #5
  6. By the way, Ara Howard suggested a really simple Drb session daemon to
    me earlier:

    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/88815

    Only I was having problems with it that I couldn't quite figure out.

    Carl

    On Tue, 27 Jul 2004 16:28:50 -0700, Carl Youngblood
    <> wrote:
    > I'd like to see a Drb-based store, so that you could have the speed of
    > memory-based access along with the ability to have a dedicated session
    > server for seamless failover of webservers behind a hardware load
    > balancer.
    >
    > Carl
    >
    >
    >
    > On Wed, 28 Jul 2004 08:21:55 +0900, Tim Bates <> wrote:
    > > David Heinemeier Hansson wrote:
    > > > On that note, does anyone have a database store for CGI::Session? It
    > > > would be nice to ship that with Rails as an option.

    > >
    > > I already told you I'd send you my CGI::Session::ActiveRecordStore. See
    > > off-list.
    > >
    > > Tim.
    > >
    > > --
    > > Tim Bates
    > >
    > >
    > >

    >
     
    Carl Youngblood, Jul 28, 2004
    #6
  7. > I'd like to see a Drb-based store, so that you could have the speed of
    > memory-based access along with the ability to have a dedicated session
    > server for seamless failover of webservers behind a hardware load
    > balancer.


    It's already there! ;)

    Have a look in vendor/actionpack/cgi_ext -- there's both a server and a
    client (Session store). Works great too and it's pretty fast.
    --
    David Heinemeier Hansson,
    http://www.rubyonrails.org/ -- Web-application framework for Ruby
    http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
    http://www.basecamphq.com/ -- Web-based Project Management
    http://www.loudthinking.com/ -- Broadcasting Brain
    http://www.nextangle.com/ -- Development & Consulting Services
     
    David Heinemeier Hansson, Jul 28, 2004
    #7
  8. >> On that note, does anyone have a database store for CGI::Session? It
    >> would be nice to ship that with Rails as an option.

    >
    > I already told you I'd send you my CGI::Session::ActiveRecordStore.
    > See off-list.


    I apologies for my forgetfullness. Marvelous job, Bates. It'll
    certainly make the upcoming 0.7.6 release!
    --
    David Heinemeier Hansson,
    http://www.rubyonrails.org/ -- Web-application framework for Ruby
    http://www.instiki.org/ -- A No-Step-Three Wiki in Ruby
    http://www.basecamphq.com/ -- Web-based Project Management
    http://www.loudthinking.com/ -- Broadcasting Brain
    http://www.nextangle.com/ -- Development & Consulting Services
     
    David Heinemeier Hansson, Jul 28, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Cox [Microsoft MVP]

    Re: Relationship between IIS Sessions and ASP.NET Sessions?

    Ken Cox [Microsoft MVP], Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,380
    Luther Miller
    Aug 8, 2003
  2. scottymo
    Replies:
    3
    Views:
    719
    Dominick Baier
    Sep 30, 2006
  3. Bookham Measures

    Moving from ASP Sessions to Database Sessions

    Bookham Measures, Jul 23, 2007, in forum: ASP General
    Replies:
    19
    Views:
    579
    Bookham Measures
    Aug 23, 2007
  4. David Heinemeier Hansson
    Replies:
    0
    Views:
    236
    David Heinemeier Hansson
    Dec 23, 2004
  5. T. W. Urp
    Replies:
    4
    Views:
    117
    Giles Bowkett
    Feb 26, 2007
Loading...

Share This Page