Class CGIKit::Cookie
In: lib/cgikit/cookie.rb
Parent: Object

Cookie is a class for cookie. To send cookies to a browser needs to create cookie objects and set them to a response object. Instead of creating cookie objects, you can also get cookie objects from a request object.

Cookie objects have a pair of a cookie name and value. If you make the objects have multiple values for one name, you must write code by yourself.

Controlling cookie objects

Creating cookies

Give arguments of initialize() a name or a pair of name/value. The value of cookie is omittable.

 cookie = Cookie.new( name, value )

Getting cookies from a request object

Request has some methods for getting cookies. The methods are cookie(key), cookies, cookie_value(key), cookie_values(key). See also Request.

Setting cookies to a response object

Response has methods for setting cookies. These methods are defined in Message, the superclass of Response. Use add_cookie(cookie) and remove_cookie(cookie).

Methods

new   parse_raw_cookie   to_s  

Attributes

domain  [RW]  Domain that can receive the cookie.
expires  [RW]  Expiry date. You set Time object to the cookie object. The value is formatted when the cookie is returned.
name  [RW]  Name of the cookie.
path  [RW]  Restricts the cookie in the site.
secure  [RW]  Decides whether the cookie is encrypted or not.
value  [RW]  Value of the cookie.

Public Class methods

Parse raw cookie string and return an array of cookies.

Public Instance methods

[Validate]