#!/usr/bin/perl -w use strict; use WWW::Mechanize; my $cookie_file = "/tmp/cookies"; my $agent = WWW::Mechanize->new(); if (! -s $cookie_file){ $agent->get("http://okopnik.com/PHP/other/cookies.php"); # Save the cookie from this session $agent->cookie_jar->save($cookie_file); } else { $agent->cookie_jar->load($cookie_file); $agent->get("http://okopnik.com/PHP/other/cookies.php"); } print $agent->content; #### ben@Tyr:/tmp$ ./cookie_test Cookies

This page comes with yummy cookies. It started at 1226629378, has been
reloaded 0 times, and has lasted 0 seconds.

ben@Tyr:/tmp$ ./cookie_test Cookies

This page comes with yummy cookies. It started at 1226629378, has been
reloaded 1 time, and has lasted 6 seconds.