| Tripletail documentation | Contained in the Tripletail distribution. |
Tripletail::Cookie - 独自のクッキー管理を行う
my $cookie = $TL->getCookie;
my $form = $cookie->get('Cookie1');
my $val = $form->get('key1');
$form->set(key2 => 100);
$cookie->set('Cookie1' => $form);
Tripletail::Form クラスのインスタンスをクッキーに保存し、 また、クッキーから Tripletail::Form を取り出す。
クッキー有効期限、ドメイン、パス等は、 ini ファイルで指定する。
$TL->getCookie $cookie = $TL->getCookie($inigroup)
$cookie = $TL->getCookie('Cookie')
Tripletail::Cookie オブジェクトを取得。 引数には Ini で設定したグループ名を渡す。 引数省略時は 'Cookie' グループが使用される。
get$Form_obj = $cookie->get($cookiename)
指定された名前のクッキーの内容を Tripletail::Form のインスタンスに変換し、返す。 返された Tripletail::Form インスタンスへの変更はクッキーへ反映されない。
set$cookie->set($cookiename => $Form_obj)
Tripletail::Form クラスのインスタンスの内容を、指定された名前のクッキーとしてセットする。
delete$cookie->delete($cookiename)
クッキーを消去する。
clear$cookie->clear
全てのクッキーを削除する。
path = /cgi-bin
クッキーのパス。省略可能。デフォルトは省略した場合と同様。
domain = example.org
クッキーのドメイン。省略可能。デフォルトは省略した場合と同様。
expires = 30 days
クッキー有効期限。 度量衡 参照。省略可能。 省略時はブラウザが閉じられるまでとなる。
secure = 1
secureフラグの有無。省略可能。
1の場合、secureフラグを付ける。
0の場合、secureフラグを付けない。
デフォルトは0。
httponly = 1
httponlyフラグの有無。省略可能。
1の場合、httponlyフラグを付ける。
0の場合、httponlyフラグを付けない。
デフォルトは0。
現状では IE でしか意味が無い。
Tripletail::Form でなく生の文字列を扱うクッキークラス。
Copyright 2006 YMIRLINK Inc.
This framework is free software; you can redistribute it and/or modify it under the same terms as Perl itself
このフレームワークはフリーソフトウェアです。あなたは Perl と同じライセンスの 元で再配布及び変更を行うことが出来ます。
Address bug reports and comments to: tl@tripletail.jp
HP : http://tripletail.jp/
| Tripletail documentation | Contained in the Tripletail distribution. |
# ----------------------------------------------------------------------------- # Tripletail::Cookie - ç¬èªã®ã¯ããã¼ç®¡çãè¡ã # ----------------------------------------------------------------------------- package Tripletail::Cookie; use strict; use warnings; use Tripletail; require Tripletail::RawCookie; our @ISA = qw(Tripletail::RawCookie); sub _POST_REQUEST_HOOK_PRIORITY() { -3_000_000 } # é åºã¯åããªã our $_INSTANCES = {}; # group => Tripletail::Cookie 1; sub _getInstance { my $class = shift; my $group = shift; if(!defined($group)) { $group = 'Cookie'; } my $obj = $_INSTANCES->{$group}; if($obj) { return $obj; } $obj = $_INSTANCES->{$group} = $class->__new($group); # postRequestããã¯ã«ãä¿åããã¦ããã¤ã³ã¹ã¿ã³ã¹ãåé¤ãã颿°ã # ã¤ã³ã¹ãã¼ã«ãããããããªããã°FCGIã¢ã¼ãã§éå»ã®ãªã¯ã¨ã¹ãã®ã¯ããã¼ã # ãã¤ã¾ã§ãæ®ãã $TL->setHook( 'postRequest', _POST_REQUEST_HOOK_PRIORITY, sub { if(%$_INSTANCES) { %$_INSTANCES = (); #$TL->log('Tripletail::Cookie' => 'Deleted cookie object made in this request.'); } }, ); $obj; } sub get { my $this = shift; my $name = shift; my $raw = $this->SUPER::get($name); if(defined($raw)) { $TL->newForm->_thaw($raw); } else { $TL->newForm; } } sub set { my $this = shift; my $name = shift; my $form = shift; if(!defined($form)) { die __PACKAGE__."#set: arg[2] is not defined. (第2弿°ãæå®ããã¦ãã¾ãã)\n"; } elsif(ref($form) ne 'Tripletail::Form') { die __PACKAGE__."#set: arg[2] is not an instance of Tripletail::Form. (第2弿°ãFormãªãã¸ã§ã¯ãã§ã¯ããã¾ãã)\n"; } my $raw = $form->_freeze; $this->SUPER::set($name => $raw); } sub _makeSetCookies { # Set-Cookie:ã®å¤ã¨ãã¦ä½¿ããããã«ã¯ããã¼ãæåååããã¯ã©ã¹ã¡ã½ããã # çµæã¯é åã§è¿ãããã my $class = shift; my @result; foreach my $this (values %$_INSTANCES) { push @result, $this->__makeSetCookie; } @result; } __END__