
At ClearCove Consulting we help our clients
run their operations like a well oiled machine.
We specialize in building software with Ruby on Rails.
If your Rails app requires cookies, this recipe is for you: It detects whether cookies are enabled, and if not, shows a message to your users.
This recipe checks for the presence of a specific cookie (“cookie_test”). If it is present, the request continues normally. If it is not present, then it sets the cookie, redirects to the “cookie_test” action and checks there whether the cookie is present. If the cookie is present, then everything continues on normally. If the cookie is still not present, then this is a strong indication that the user has cookies disabled. Then the recipe shows a page to the user explaining the cookie requirement. I leave it up to you to write the copy for that page.

Flow chart for the cookie detection recipe
This recipe works as of Rails 2.3 (new cookie handling). It is inspired by this article. The recipe in the original article does not work with newer versions of rails. So I updated it and packaged it up in a neat little module that you can include in your application controller.
We built our first commercial web application in 1998 — that was before the first Internet bubble burst.
We have built many web apps since then and have started working with Ruby on Rails in 2005.