Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActionController::Flash::InstanceMethods::flash triggers the lazy sessions

#2449

I've just updated to rails 2.3 and I found that calling flash from the view triggers the lazy sessions. I think this is not the expected behavior.

See the patch attached

Reported by runa · April 7th, 2009 @ 11:25 PM

State: duplicate
Milestone: 2.3.9
Assigned to: josh josh
Importance: none

Activity

  1. runa
  2. Stefan Botzenhart
    Stefan Botzenhart

    Any comments on this ticket? I realized the same thing when trying to cache my application with varnish. As flash triggers the session and sets the "Set-Cookie" header although the session is empty varnish is not willing to cache the page.

    September 23rd, 2009 @ 08:36 AM

  3. runa
    runa

    Maybe we need to lobby a little for this?

    September 23rd, 2009 @ 02:14 PM

  4. Urban Hafner
    Urban Hafner
    • Tag changed from 2.3.2, flash, lazy, sessions to 2.3.2, 2.3.x, flash, lazy, sessions

    Check out this plugin: http://github.com/msales/smart_cookie_store

    It enhances the default CookieStore by preventing Set-Cookie headers for empty sessions.

    January 29th, 2010 @ 03:15 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 2.3.6
    • State changed from new to open
    • Assigned user set to josh

    January 29th, 2010 @ 11:51 PM

  6. josh
    josh
    • State changed from open to resolved

    I think this is related to:

    #3811 Empty Set-Cookie header

    February 2nd, 2010 @ 02:56 PM

  7. Urban Hafner
    Urban Hafner

    It is related. How did you fix it? The fix for #3811 Empty Set-Cookie header isn't enough.

    February 2nd, 2010 @ 03:00 PM

  8. Urban Hafner
    Urban Hafner
    • Tag changed from 2.3.2, 2.3.x, flash, lazy, sessions to 2-3-stable, 2.3.2, 2.3.x, 3, 3.0, flash, lazy, sessions

    I had a look and it's not fixed in the latest 2-3-stable. Attached is a diff that contains a test and possible fix (but the fix breaks the reset session functionality). To recap, the problem is that even when you only try to access something in the session (like for example a flash[:notice] in the layout) a session cookie gets set. Even if it is empty and there's no need for it.

    I'm not quite sure about Rails 3, but the bug seems to be present there, too.

    February 5th, 2010 @ 10:02 AM

  9. Urban Hafner
    Urban Hafner

    BTW, sorry for the typo in the test case ;)

    February 5th, 2010 @ 10:03 AM

  10. Urban Hafner
    Urban Hafner
    • Tag changed from 2-3-stable, 2.3.2, 2.3.x, 3, 3.0, flash, lazy, sessions to 2-3-stable, 2.3.2, 2.3.x, 3, 3.0, 3.0pre, flash, lazy, sessions

    I just tested it and the bug is still present in Rails 2.3 (latest version of the branch) and in master. However in master my fix doesn't work (even after the obvious changes necessary to have a look).

    February 26th, 2010 @ 01:41 PM

  11. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.6 to 2.3.9
    • State changed from resolved to open

    June 18th, 2010 @ 11:24 PM

  12. José Valim
    José Valim
    • State changed from open to duplicate
    • Importance changed from to

    Fixed on master. When #4938 [PATCH] Session fixes: sessions should not be created until written to; and s... is backported, this will be fixed as well.

    June 26th, 2010 @ 09:12 AM