Skip to content

Instantly share code, notes, and snippets.

@gorsuch
Forked from ibdknox/cookies.clj
Created July 25, 2011 21:29
Show Gist options
  • Select an option

  • Save gorsuch/1105280 to your computer and use it in GitHub Desktop.

Select an option

Save gorsuch/1105280 to your computer and use it in GitHub Desktop.

Revisions

  1. gorsuch revised this gist Jul 25, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions flash.clj
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    (session/flash-put! "User added!")
    (session/get-flash)
    (session/flash-get)
    ;; => "User added!"
    ;;
    (session/get-flash)
    (session/flash-get)
    ;; => nil
  2. @ibdknox ibdknox revised this gist Jul 25, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion testing.clj
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,4 @@
    (deftest cookies-get
    (with-noir
    (is (nil? (cookies/get :noir)))
    (is (= "noir" (cookies/get :noir "noir")))))
    (is (= "noir" (cookies/get :noir "noir")))))
  3. @ibdknox ibdknox revised this gist Jul 25, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cookies.clj
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,4 @@
    ;; => "anon"

    ;; you can also pass a map that has all the cookie's attributes
    (cookies/put! :tracker {:value 29649 :path "/" :expires 1})
    (cookies/put! :tracker {:value 29649 :path "/" :expires 1})
  4. @ibdknox ibdknox revised this gist Jul 25, 2011. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions testing.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    (use 'noir.util.test)

    (deftest cookies-get
    (with-noir
    (is (nil? (cookies/get :noir)))
    (is (= "noir" (cookies/get :noir "noir")))))
  5. @ibdknox ibdknox revised this gist Jul 25, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cookies.clj
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,4 @@
    ;; => "anon"

    ;; you can also pass a map that has all the cookie's attributes
    (cookies/put! :tracker {:value 29649 :path "/" :expires 1})
    (cookies/put! :tracker {:value 29649 :path "/" :expires 1})
  6. @ibdknox ibdknox revised this gist Jul 25, 2011. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion flash.clj
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,4 @@
    ;; => "User added!"
    ;;
    (session/get-flash)
    ;; => nil
    ;; => nil
    2 changes: 1 addition & 1 deletion session.clj
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,4 @@

    (session/put! :username "chris")
    (session/put! :user-id 2)
    (session/clear!)
    (session/clear!)
  7. @ibdknox ibdknox revised this gist Jul 25, 2011. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions cookies.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    (require '[noir.cookies :as cookies])

    (cookies/put! :user-id 2)
    (cookies/get :user-id)
    ;; => 2

    (cookies/get :username "anon")
    ;; => "anon"

    ;; you can also pass a map that has all the cookie's attributes
    (cookies/put! :tracker {:value 29649 :path "/" :expires 1})
  8. @ibdknox ibdknox revised this gist Jul 25, 2011. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion flash.clj
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,4 @@
    ;; => "User added!"
    ;;
    (session/get-flash)
    ;; => nil
    ;; => nil
    2 changes: 1 addition & 1 deletion session.clj
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,4 @@

    (session/put! :username "chris")
    (session/put! :user-id 2)
    (session/clear!)
    (session/clear!)
  9. @ibdknox ibdknox revised this gist Jul 25, 2011. 2 changed files with 22 additions and 1 deletion.
    6 changes: 6 additions & 0 deletions flash.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    (session/flash-put! "User added!")
    (session/get-flash)
    ;; => "User added!"
    ;;
    (session/get-flash)
    ;; => nil
    17 changes: 16 additions & 1 deletion session.clj
    Original file line number Diff line number Diff line change
    @@ -1 +1,16 @@
    (require '[noir.session :as session])
    (require '[noir.session :as session])

    (session/put! :username "chris")
    (session/get :username)
    ;; => "chris"

    (session/remove! :username)
    (session/get :username)
    ;; => nil

    (session/get :username "anon")
    ;; => "anon"

    (session/put! :username "chris")
    (session/put! :user-id 2)
    (session/clear!)
  10. @ibdknox ibdknox created this gist Jul 25, 2011.
    1 change: 1 addition & 0 deletions session.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    (require '[noir.session :as session])