This project is archived and is in readonly mode.

#2733 ✓resolved
Olly

[PATCH] Memoize cookies so they can be retrieved in the same response / request cycle

Reported by Olly | May 28th, 2009 @ 01:40 PM | in 2.3.4

If you set a cookie in a controller action and then try and access the new value in later in the action or in the view, the old value for the cookie is retrieved because the CookieJar is re-initialized with each call to ActionController::Base#cookies.

# Contrived example
# Before patch:
def show
  cookies[:logged_in] = true
  cookies[:logged_in] # => nil
end

# After patch:
def show
  cookies[:logged_in] = true
  cookies[:logged_in] # => true
end

Related thread on Core mailing list.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Tags