Skip to main content
Home
Live to Learn!

Main navigation

  • Home
  • Learn
    • FoxPro
    • MS-DOS
    • C PRG
    • Java
    • ASP
    • Ruby on Rails
    • ASP.NET
    • E-Books
    • Exam Preparation
    • Tools
  • Blog
  • Forums
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Ruby and Rails

Cookies Management in Ruby on Rails

Book navigation

  • Single line swapping in Ruby
  • Array Operations in Ruby
  • File operations in Ruby
  • User defined functions in Ruby
  • Classes and Objects in Ruby
  • Simple Form Hello Rails Application
  • Database Application using scaffold - [Video]
  • Session Management
  • Cookies Management in Ruby on Rails
  • File Uploads in Ruby on Rails
By Karthikeyan , 25 October, 2012

Example #1:
This program sets cookie (customer) and reads.

Controller


class LookController < ApplicationController
  def index
    set
    render :action=>"set"
  end
  def read
    @cookie_data = cookies[:customer]
  end
  def set
    cookies[:customer]={:vaule=>"xxxxx", :expires=>31.days.from_now}
  end
end

Views


set.html.erb

Setting a cookie

The cookie was set click <%=link_to "here", :action=>"read"%> read the cookie
read.html.erb

Reading a cookie

The cookie says the customer is <%=@cookie_data%>
  • Add new comment

Comments

Featured Blog Posts

Convert Currency in Number to Words (Indian Rupees) - MS Excel
Foxpro Tutorial and Programs
Convert Currency in Number to Words in MS Word
Convert Currency in Number to Words (Indian Rupees) - Version 2
Best way to Use Rupee Symbol in Windows – Easy steps
Convert Currency in Number to Words - MS Access
Creating All in One Windows XP DVD with all Important Applications
RSS feed

© 2009-2025 Live to Learn.In

Terms of Use | Privacy Policy