要約
クッキーを表すクラスです。
例:
cookie1 = CGI::Cookie.new("name", "value1", "value2", ...)
cookie1 = CGI::Cookie.new({"name" => "name", "value" => "value"})
cookie1 = CGI::Cookie.new({'name'      => 'name',
                           'value'     => ['value1', 'value2', ...],
                           'path'      => 'path',   # optional
                           'domain'    => 'domain', # optional
                           'expires'   => Time.now, # optional
                           'secure'    => true      # optional
                           'httponly'  => true      # optional
                          })
cgi.out({"cookie" => [cookie1, cookie2]}){ "string" }
name      = cookie1.name
values    = cookie1.value
path      = cookie1.path
domain    = cookie1.domain
expires   = cookie1.expires
secure    = cookie1.secure
httponly  = cookie1.httponly
cookie1.name      = 'name'
cookie1.value     = ['value1', 'value2', ...]
cookie1.path      = 'path'
cookie1.domain    = 'domain'
cookie1.expires   = Time.now + 30
cookie1.secure    = true
cookie1.httponly  = true
@see [RFC2965]
目次
- 特異メソッド
- インスタンスメソッド
継承しているメソッド
- Arrayから継承しているメソッド
- 
  - &
- *
- +
- -
- <<
- <=>
- ==
- []
- []=
- all?
- any?
- append
- assoc
- at
- bsearch
- bsearch_index
- clear
- clone
- collect
- collect!
- combination
- compact
- compact!
- concat
- count
- cycle
- delete
- delete_at
- delete_if
- difference
- dig
- drop
- drop_while
- dup
- each
- each_index
- empty?
- eql?
- fetch
- fill
- filter
- filter!
- find_index
- first
- flatten
- flatten!
- hash
- include?
- index
- insert
- inspect
- intersect?
- intersection
- join
- keep_if
- last
- length
- map
- map!
- max
- min
- minmax
- none?
- one?
- pack
- permutation
- pop
- prepend
- product
- push
- rassoc
- reject
- reject!
- repeated_combination
- repeated_permutation
- replace
- reverse
- reverse!
- reverse_each
- rindex
- rotate
- rotate!
- sample
- select
- select!
- shift
- shuffle
- shuffle!
- size
- slice
- slice!
- sort
- sort!
- sort_by!
- sum
- take
- take_while
- to_a
- to_ary
- to_h
- transpose
- union
- uniq
- uniq!
- unshift
- values_at
- zip
- |
 
- Enumerableから継承しているメソッド
特異メソッド
- new(name = "", *value) -> CGI::Cookie[permalink][rdoc][edit]
- 
クッキーオブジェクトを作成します。 第一引数にハッシュを指定する場合は、以下のキーが使用可能です。 - name
- 
クッキーの名前を指定します。必須。 
- value
- 
クッキーの値、または値のリストを指定します。 
- path
- 
このクッキーを適用するパスを指定します。デフォルトはこの CGI スクリプトのベースディレクトリです。 
- domain
- 
このクッキーを適用するドメインを指定します。 
- expires
- 
このクッキーの有効期限を Time のインスタンスで指定します。 
- secure
- 
真を指定すると、このクッキーはセキュアクッキーになります。デフォルトは偽です。セキュアクッキーは HTTPS の時のみ送信されます。 
- httponly
- 
真を指定すると、このクッキーはhttpオンリークッキーになります。デフォルトは偽です。httpオンリークッキーはjavascriptからアクセスできません。 
 - [PARAM] name:
- クッキーの名前を文字列で指定します。クッキーの名前と値を要素とするハッシュを指定します。
- [PARAM] value:
- name が文字列である場合、値のリストを一つ以上指定します。
 例: cookie1 = CGI::Cookie.new("name", "value1", "value2", ...) cookie1 = CGI::Cookie.new({"name" => "name", "value" => "value"}) cookie1 = CGI::Cookie.new({'name' => 'name', 'value' => ['value1', 'value2', ...], 'path' => 'path', # optional 'domain' => 'domain', # optional 'expires' => Time.now, # optional 'secure' => true # optional 'httponly' => true # optional }) cgi.out({"cookie" => [cookie1, cookie2]}){ "string" } name = cookie1.name values = cookie1.value path = cookie1.path domain = cookie1.domain expires = cookie1.expires secure = cookie1.secure httponly = cookie1.httponly cookie1.name = 'name' cookie1.value = ['value1', 'value2', ...] cookie1.path = 'path' cookie1.domain = 'domain' cookie1.expires = Time.now + 30 cookie1.secure = true cookie1.httponly = true
- parse(raw_cookie) -> Hash[permalink][rdoc][edit]
- 
クッキー文字列をパースします。 - [PARAM] raw_cookie:
- 生のクッキーを表す文字列を指定します。
 例: cookies = CGI::Cookie.parse("raw_cookie_string") # { "name1" => cookie1, "name2" => cookie2, ... }
インスタンスメソッド
- domain -> String[permalink][rdoc][edit]
- 
クッキーを適用するドメインを返します。 
- domain=(value)[permalink][rdoc][edit]
- 
クッキーを適用するドメインをセットします。 - [PARAM] value:
- ドメインを指定します。
 
- expires -> Time[permalink][rdoc][edit]
- 
クッキーの有効期限を返します。 
- expires=(value)[permalink][rdoc][edit]
- 
クッキーの有効期限をセットします。 - [PARAM] value:
- 有効期限を Time のインスタンスで指定します。
 
- httopnly -> bool[permalink][rdoc][edit]
- 
自身がhttpオンリークッキーである場合は、真を返します。そうでない場合は、偽を返します。 
- httopnly=(val)[permalink][rdoc][edit]
- 
httpオンリークッキーであるかどうかを変更します。 - [PARAM] val:
- 真を指定すると自身はhttpオンリークッキーになります。
 
- name -> String[permalink][rdoc][edit]
- 
クッキーの名前を返します。 
- name=(value)[permalink][rdoc][edit]
- 
クッキーの名前をセットします。 - [PARAM] value:
- 名前を指定します。
 
- path -> String[permalink][rdoc][edit]
- 
クッキーを適用するパスを返します。 
- path=(value)[permalink][rdoc][edit]
- 
クッキーを適用するパスをセットします。 - [PARAM] value:
- パスを指定します。
 
- secure -> bool[permalink][rdoc][edit]
- 
自身がセキュアクッキーである場合は、真を返します。そうでない場合は、偽を返します。 
- secure=(val)[permalink][rdoc][edit]
- 
セキュアクッキーであるかどうかを変更します。 - [PARAM] val:
- 真を指定すると自身はセキュアクッキーになります。
 
- to_s -> String[permalink][rdoc][edit]
- 
クッキーの文字列表現を返します。 
- value -> Array[permalink][rdoc][edit]
- 
クッキーの値を返します。 
- value=(value)[permalink][rdoc][edit]
- 
クッキーの値をセットします。 - [PARAM] value:
- 変更後の値を指定します。