Look … no cookies!

It's been a long time coming, but this site is now free of cookies! This means no need to implement a cookie banner, as there is no user data being stored in cookies. Not using cookies also means users are not tracked for analytics purposes, although simple page hit statistics are captured by the server monitoring systems, these do not include any user data.

So, now for the technical details. This site is currently built with the Rails framework and the Ruby programming language. Rails provides easy access to configure how cookies store data on the users browser, as well as easy methods to remove cookies from the users browser. For this site, cookies are only used when accessing the admin pages; normal users of the site will never have any information tracked in cookies. To achieve this, we can user a Rails after_action instruction in the application_controller that ensures cookies are removed from every page, except when a user is logged into the admin pages:

  # app/controllers/application_controller.rb
  after_action do
    cookies.delete(Rails.application.config.session_options[:key]) unless user_signed_in?
    request.session_options[:skip] = !(user_signed_in? || devise_controller?)
  end

About the Author

Phil Balchin is a full-time software developer at Zendesk, previously at Heroku/Salesforce, and Kyan, as well as a part-time photographer living in Guildford, Surrey, UK.

facebook.com/phil.balchin | instagram.com/maniacalrobot | last.fm/users/maniacalrobot | picfair.com/maniacalrobot | maniacalrobot.tumblr.com | twitter.com/maniacalrobot

Posts in this series

Related Posts