- 论坛徽章:
- 0
|
原帖由 chopper7278 于 2008-4-7 17:16 发表
$session->expire('+30s');
我试过这个貌似没删除。。。help
你在第一个帖子里还说用$s->delete()来的,现在怎么不用了?
- 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.
复制代码
我的印象里好像有的session实现可以设置一定的几率触发自己去清理过期的session,不过不记得是CGI-session还是php的了
你也可以自己写个程序隔三差五的清理清理
[ 本帖最后由 tmp 于 2008-4-8 15:38 编辑 ] |
|