CGI::C...plitter(3pm)

πŸ“¦
version 0.05 Β· 2 versions
  • 0.05 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.05 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

okay bestie, sit down, we're talking about CGI::Cookie::Splitter β€” the manual page you're reading rn is CGI::C...plitter(3pm) (the truncation is giving very "my name didn't fit on the bus", iconic honestly) ✨

🌸 NAME 🌸

CGI::Cookie::Splitter β€” split big cookies into smaller ones. that's it, that's the whole job, and she does it flawlessly πŸ’…

πŸŽ€ VERSION πŸŽ€

version 0.05


πŸ¦‹ SYNOPSIS πŸ¦‹

use CGI::Cookie::Splitter;

my $splitter = CGI::Cookie::Splitter->new(
    size => 123, # defaults to 4096
);

@small_cookies = $splitter->split( @big_cookies );

@big_cookies = $splitter->join( @small_cookies );

look at that. clean. no notes. πŸ’–


🌈 DESCRIPTION 🌈

okay so here's the tea: RFC 2109 says the smallest cookie size a client is expected to support is 4096 bytes. that number has basically become the standard, and if your server is out here yeeting cookies bigger than that, it's considered a no-no. like, the vibe check has been failed, fr fr 😭

this module hands you a pretty simple interface for generating small cookies that stay under a certain limit, without wasting too much effort. low effort, high reward, main character energy πŸ‘‘


✨ METHODS ✨

πŸ’œ new

$splitter = CGI::Cookie::Splitter->new(%params)

the only parameter supported right now is size. it defaults to 4096. that's the whole constructor. she's low maintenance 🫢

πŸ’œ split

@cookies = $splitter->split(@cookies)

this method takes a list of CGI::Cookie objects (or lookalikes β€” we don't gatekeep, if it walks like a cookie and talks like a cookie, we'll work with it πŸ’…) and returns a list of CGI::Cookies.

whenever an object shows up whose total size is bigger than the limit you set at construction time, it gets replaced in the result list with several objects of the same class. those new ones get assigned serial names, and they have a smaller size and the same domain/path/expires/secure parameters. so nothing important gets lost in the glow-up, periodt.

πŸ’œ join

$cookie = $splitter->join(@cookies)

this is the inverse of split. gluing the little guys back into one big guy. 🧚

πŸ’œ should_split

$splitter->should_split($cookie)

whether or not the cookie should be split. the vibe check, but for cookies. πŸ“

πŸ’œ mangle_name_next

$splitter->mangle_name_next($name)

πŸ’œ mangle_name

$splitter->mangle_name($name, $index)

πŸ’œ demangle_name

$splitter->demangle_name($mangled_name)

these methods encapsulate a name mangling scheme for changing the cookie names to allow a 1:n relationship. one name, many cookies. she contains multitudes 🌸

⚠️ bestie listen β€” the default mangling behavior is not 100% safe, because cookies with a safe size are not mangled. not a drill, just a fact, say it with me πŸ™ˆ

as long as your cookie names don't start with the substring "_bigcookie_" you should be OK ;-) πŸ’€

demangles name, increments the index and remangles. yes that's a little chaotic. no we're not changing it.


🌟 SUBCLASSING 🌟

this module is designed to be easily subclassed... if you need to split cookies using a different criteria then you should look into that. go off, build your own, I support you πŸ‘‘


πŸŽ€ SEE ALSO πŸŽ€

the copper moose cutter image is genuinely essential reading btw, iykyk πŸ¦‹


πŸ’– AUTHOR πŸ’–

Χ™Χ•Χ‘Χœ Χ§Χ•Χ’'מן (Yuval Kogman) <nothingmuch@woobling.org>

🌸 CONTRIBUTORS 🌸

  • Karen Etheridge <ether@cpan.org>
  • Shlomi Fish <shlomif@cpan.org>

this software is copyright (c) 2006 by Χ™Χ•Χ‘Χœ Χ§Χ•Χ’'מן (Yuval Kogman).

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay πŸ’…


okay that's the whole page bestie, go forth and split responsibly 🌈✨

perl v5.34.0 Β· 2022-06-09 Β· CGI::C...plitter(3pm) β€” that's the version and date stamp from the footer, love that for us, mwah πŸ’–πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from