📄 session.pm
字号:
# Copyright 2001-2005 Six Apart.# SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS## $Id: Session.pm 10834 2005-03-30 23:32:02Z ezra $package MT::Session;use strict;use MT::Object;@MT::Session::ISA = qw( MT::Object );__PACKAGE__->install_properties({ columns => [ qw(id data email name kind start) ], indexes => { id => 1, start => 1, kind => 1 }, datasource => 'session',});sub get_unexpired_value { my $timeout = shift; my $candidate = __PACKAGE__->load(@_); if ($candidate && $candidate->start() < time - $timeout) { $candidate->remove(); $candidate = undef; } return $candidate;}1;__END__=pod=head1 NAMEMT::Session - temporary storage of arbitrary data.=head1 SYNOPSISProvides for the storage of arbitrary temporary data. The name"session" is a hold-over from the days when commenter sessions werethe only kind of temporary data that MT stored.A piece of temporary data is identified uniquely by an ID, but it alsohas a "kind," a two-character identifier that separates differentusages of the table. The C<id> value must be distinct across allkinds.Each kind is associated with a fixed timeout window; records olderthan that amount are deleted automatically. Currently-used kinds areas follows:=over 4=item SIActive commenter sessions are held in SI sessions.=item KYThe public key of the remote comment authentication service is held inthe I<single> record of kind 'KY'.=item AN"Nonce" values (used for certain authentication systems) are storedwith a kind of 'AN'.=item NWThe cached contents of the newsbox (top right of MT's welcome screen)is held in the I<single> record of kind 'NW'.=head1 METHODS=head2 $sess = MT::Session->get_unexpired_value($timeout, [ $terms, [ $args, ... ] ]);Fetches the specified session record, if it is current (its C<start>field falls within last $timeout seconds). Arguments following the$timeout argument are passed directly to C<MT::Object::load>.=cut
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -