Skip to content

Ring middleware library for sending "permanent" visitor-identifying cookies.

Notifications You must be signed in to change notification settings

cvillecsteele/permacookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

permacookie

Sends a cookie to the browser that will "permanently" identify that visitor.

Usage

Defines a ring middleware function at ring.middleware.permacookie/wrap-permacookie.

Your usage might resemble:

    `(ns mine.core
      (:use [compojure.core]
            [ring.adapter.jetty]
            [ring.middleware.cookies]
            [ring.middleware.permacookie]))
    (defroutes webservice
      (GET "/" [] (fn [req] {:body (str "You are: " (:visitor-id req))})))
    (def app (-> (var webservice)
                 (wrap-permacookie {:name "nifty"})
                 wrap-cookies))
    (run-jetty #'app {:port 2000})`

This middlware places a permanent cookie on the visitor's browser, with a unique identifier. That identifier is then made available through the :visitor-id key on the request map which is available to handlers.

Installation

For lein, in your project.clj:

    [org.clojars.cvillecsteele/ring-permacookie-middleware "1.4.0"]

License

Copyright (C) 2010 Colin Steele (colin@colinsteele.org)

Distributed under the Eclipse Public License, the same as Clojure.

About

Ring middleware library for sending "permanent" visitor-identifying cookies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published