Skip to content

Instantly share code, notes, and snippets.

@biilmann
Created March 17, 2010 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biilmann/335854 to your computer and use it in GitHub Desktop.
Save biilmann/335854 to your computer and use it in GitHub Desktop.
class CookieTestController < ApplicationController
def set_cookie
cookies.delete :hello
cookies[:hello] = { :value => "Hello there at #{Time.now}!", :expires => 2.weeks.from_now }
render :text => "cookie set to: #{cookies[:hello]}"
end
 
def view_cookie
render :text => "Cookie: #{cookies[:hello]}"
end
end
GET /set_cookie
cookie set to: Hello there at Thu Mar 18 00:27:07 +0100 2010!
GET /view_cookie
Cookie:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment