CKCookie

Class/Module:
Class
In:
lib/cgikit.rb
Parent:
Object

Description

CKCookie 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.

CKCookie 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 = CKCookie.new( name, value )

Getting cookies from a request object

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

Setting cookies to a response object

CKResponse has methods for setting cookies. These methods are defined in CKMessage, the superclass of CKResponse. 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

new( name, value = nil, domain = nil, path = nil, secure = false )
parse_raw_cookie( raw_cookie )

Parse raw cookie string and return an array of cookies.

Public Instance Methods

to_s()