- 論壇徽章:
- 0
|
原帖由 chopper7278 于 2008-4-7 17:16 發(fā)表 ![]()
$session->expire('+30s');
我試過這個(gè)貌似沒刪除。。。help
你在第一個(gè)帖子里還說用$s->delete()來的,現(xiàn)在怎么不用了?
- find( \&code )
- find( $dsn, \&code )
- find( $dsn, \&code, \%dsn_args )
- Experimental feature. Executes \&code for every session object stored in disk, passing initialized CGI::Session
- object as the first argument of \&code. Useful for housekeeping purposes, such as for removing expired sessions.
- Following line, for instance, will remove sessions already expired, but are still in disk:
- The following line, for instance, will remove sessions already expired, but which are still on disk:
- CGI::Session->find( sub {} );
- Notice, above \&code didn't have to do anything, because load(), which is called to initialize sessions inside
- find(), will automatically remove expired sessions. Following example will remove all the objects that are 10+
- days old:
- CGI::Session->find( \&purge );
- sub purge {
- my ($session) = @_;
- next if $session->is_empty; # <-- already expired?!
- if ( ($session->ctime + 3600*240) <= time() ) {
- $session->delete() or warn "couldn't remove " . $session->id . ": " . $session->errstr;
- }
- }
- Note: find will not change the modification or access times on the sessions it returns.
復(fù)制代碼
我的印象里好像有的session實(shí)現(xiàn)可以設(shè)置一定的幾率觸發(fā)自己去清理過期的session,不過不記得是CGI-session還是php的了
你也可以自己寫個(gè)程序隔三差五的清理清理
[ 本帖最后由 tmp 于 2008-4-8 15:38 編輯 ] |
|