daddyz / evercookie

evercookie gem for Ruby on Rails
MIT License
49 stars 27 forks source link

== Evercookie

{Build Status}[http://travis-ci.org/daddyz/evercookie] {Gem Version}[http://badge.fury.io/rb/evercookie] {}[https://codeclimate.com/github/daddyz/evercookie]

Evercookie is a gem allowing you to use very persistent cookies on your rails project to track existing users on your system. It's javascript is based on https://github.com/samyk/evercookie javascript. Please note, that evercookie can't be fully reliable for detecting previous visiting of your site/application. For people who know the job it's simple enough to override it.

As written on original javascript {site}[http://samy.pl/evercookie/], when creating a new cookie, it uses the following storage mechanisms when available:

== Information

=== RDoc

RDoc documentation can be found here http://rubydoc.info/github/daddyz/evercookie/master/frames

=== Bug reports

If you discover a problem with Evercookie gem, let us know about it. https://github.com/daddyz/evercookie/issues

=== Example application

You can see an example of evercookie working in test/dummy application of this gem

== Getting started

Evercookie works was written and tested on Rails 3.2/4. You can add in to your Gemfile with:

gem 'evercookie'

Run the bundle command to install it.

=== View helpers

View helper that adds javascript for setting the evercookie for client:

set_evercookie(:key, :value)

View helper that checks whether the cookie was set on client side and resets if some of cookies were deleted:

check_evercookie(:key)

=== Controller helpers

Controller helper that gets the value of evercookie by key:

evercookie_get_value(:key)

Controller helper that checks if specific evercookie was set:

evercookie_is_set?(:key) evercookie_is_set?(:key, :value)

=== How it works

When you are calling:

=== How this gem should be used

The main idea of this gem is to set somewhere in application an evercookie to track that this client already visited your application. I used it to track multiple registrations in such scenario:

=== Configuring the gem

You can create the initializer for evercookie gem in your Rails application initializers folder:

Evercookie.setup do |config|

path for evercookie controller

config.namespace = :evercookie

# name of javascript class to be used for evercookie
config.js_class = :evercookie

# hash name base for session storage variables
config.hash_name = :evercookie

# cookie name for cache storage
config.cookie_cache = :evercookie_cache

# cookie name for png storage
config.cookie_png = :evercookie_png

# cookie name for etag storage
config.cookie_etag = :evercookie_etag

# enable/disable http basic auth (leads to problems if your app uses http basic auth)
config.basic_auth = true

end

=== Hiding evercookie presence in your application

If you really want to hide that you are using evercookie you should do several things (as I see it):