HTTP::...:Cookie(3pm)
π HTTP::CookieMonster::Cookie β the manual, but make it cute πͺ
okay bestie, so this is the Perl doc page for HTTP::...:Cookie(3pm) from the User Contributed Perl Documentation, and we're gonna walk through it together. grab a snack, it's giving cookie lore. π
β¨ NAME β¨
HTTP::CookieMonster::Cookie β the cookie representation that HTTP::CookieMonster uses, periodt. πͺ
πΈ VERSION πΈ
version 0.11 β yeah she's on 0.11, keep up π
π¦ SYNOPSIS π¦
okay so here's the whole vibe in code, literally verbatim, don't touch:
use HTTP::CookieMonster::Cookie;
my $cookie = HTTP::CookieMonster::Cookie->new(
key => 'cookie-name',
val => 'cookie-val',
path => '/',
domain => '.somedomain.org',
path_spec => 1,
secure => 0,
expires => 1376081877
);
use WWW::Mechanize;
use HTTP::CookieMonster;
my $mech = WWW::Mechanize->new;
my $monster = HTTP::CookieMonster->new( cookie_jar => $mech->cookie_jar );
$monster->set_cookie( $cookie );
$mech->get('https://example.com'); # passes $cookie in request
so you make a cookie, you hand it to the monster, the monster stuffs it in mechanize's cookie jar, and then the request justβ¦ carries it. no cap. β¨
π DESCRIPTION π
so the whole point of this module is that HTTP::CookieMonster uses it to represent the cookies it finds chilling in an HTTP::Cookies cookie_jar. and to keep things familiar β because who wants to learn a whole new vocabulary β the method names were deliberately chosen to mirror the positional parameter names laid out in the $cookie_jar->scan( \&callback ) documentation. iykyk. π«Ά
real talk though: being not intimately familiar with the HTTP cookie spec, the author did not force any validation or default values onto any of the attributes. so please be aware β the burden is on you, the user, to provide "correct" data if you're using this module directly. it's giving trust falls. π
there are some sample values below, but if you want a better idea of what's actually required? try visiting a few sites and dumping their cookies. field research, bestie. π₯
use Data::Printer;
my $mech = WWW::Mechanize->new;
$mech->get( 'http://www.google.ca' );
my $monster = HTTP::CookieMonster->new( cookie_jar => $mech->cookie_jar );
p $monster->all_cookies;
β version β
$cookie->version( 0 );
π key π
The name of the cookie. that's it, that's the whole job.
$cookie->key( "session_id" );
π§ val π§
The value of the cookie. iconic.
$cookie->val( "random_stuff" );
If you are creating a new cookie, you should escape the value first. do not skip this step bestie, it's for your own good π
use URI::Escape qw( uri_escape );
$cookie->value( uri_escape( 'random_stuff' ) );
π path π
$cookie->path( "/" );
π domain π
$cookie->domain( ".google.ca" );
πΈ port πΈ
(yes, she exists. that's the whole note. slay.)
π path_spec π
$cookie->path_spec( 1 );
π secure π
$cookie->secure( 1 );
π₯ expires π₯
$cookie->expires( 1407696193 );
π discard π
(also just vibing here on her own. no example given, no example needed.)
π hash π
$cookie->hash( { HttpOnly => undef } );
π¦ SEE ALSO π¦
This is mainly useful for creating cookies to be used by LWP::UserAgent and WWW::Mechanize classes. If you need to create cookies to set via headers, have a look at Cookie::Baker. go give them a lil visit π«Ά
β¨ AUTHOR β¨
Olaf Alders <olaf@wundercounter.com> β thank you king π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2012 by Olaf Alders.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in freedom, bestie ποΈ
and that's the whole page, no notes. π
so this doc was rendered up by perl v5.36.0 on 2022-10-14, and it lives in the HTTP::...:Cookie(3pm) manual page from the User Contributed Perl Documentation. mwah, slay, go forth and cookie responsibly πͺβ¨π
π¦ where this page comes from
- ubuntu noble: libhttp-cookiemonster-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhttp-cookiemonster-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhttp-cookiemonster-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms