O'Reilly logo

Clojure Web Development Essentials by Ryan Baldwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cookies

Show me a website without any cookies, and I'll show you a pamphlet. At some point, you're going to need to write a cookie. Indeed, we've already seen that Ring writes out a cookie for us right out of the box for session tracking.

We can interact with cookies using the noir.cookies namespace. At its most basic, noir.cookies provides two functions: get and put!.

Getting a cookie's value

We can get a cookie's value by calling noir.cookies/get and providing either a string or a keyword for the name of the cookie to retrieve. We can see this in action by creating a trivial route that simply renders out the value of the ring-session cookie:

(require '[compojure.core :refer :all] '[noir.cookies :as cookies]) (defroutes some-route (GET "/ring-session" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required