develooper Front page | perl.libwww | Postings from January 2002

HTTP::Cookies::clear_session()

From:
Mike Schilli
Date:
January 27, 2002 08:16
Subject:
HTTP::Cookies::clear_session()
Message ID:
3C54295C.371F3097@pacbell.net
Hi Gisle and all,

I'd like to add a clear_session() method to HTTP::Cookies simulating
closing the browser by clearing all session cookies. Code is below ...

=item $cookie_jar->clear_session( );

Simulate closing the browser by clearing all session cookies
(which don't have an expire field set).

=cut

sub clear_session
{
    my($self) = @_;

    $self->scan(sub {
        if(not $_[8]) {    # No expire field?
            $_[8] = -1;            # Set the expire/max_age field
            $self->set_cookie(@_); # Clear the cookie
        }
      });
}

__END__

-- Mike
--------------------------------------------------------
Mike Schilli m@perlmeister.com http://perlmeister.com
--------------------------------------------------------



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About