HTML::...aptcha(3pm)

πŸ“¦
version 0.40068 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

🌸 NAME 🌸

Okay bestie, welcome to the HTML::...aptcha(3pm) page from the User Contributed Perl Documentation. This one is all about HTML::FormHandler::TraitFor::Captcha β€” generate and validate captchas. That's the name, that's the mission, we're moving. πŸ’…


πŸ¦‹ VERSION πŸ¦‹

version 0.40068 β€” write it down, bestie, that's the version of this little icon. 🫢


✨ SYNOPSIS ✨

It's a role you use in a form to implement a captcha field. Two ways to pull up, and both are valid:

package MyApp::Form;
use HTML::FormHandler::Moose;
with 'HTML::FormHandler::TraitFor::Captcha';

or

my $form = MyApp::Form->new( traits => ['HTML::FormHandler::TraitFor::Captcha'],
    ctx => $c );

Then the important bit: it needs a context object set in the form's ctx attribute. That context has a session hashref in which to store a captcha hashref β€” the kind of setup the Catalyst session plugin provides, for example. That's the requirement, periodt. πŸ’–


πŸ’… METHODS πŸ’…

get_captcha

Get a captcha stored in $form->ctx->{session}. Simple. Fetch. Slay. ✨

set_captcha

Set a captcha in $self->ctx->{session}. Put it there, bestie. πŸŽ€

captcha_image_url

The default is '/captcha/image'. Override it in a form to change it. Like this:

sub captcha_image_url { '/my/image/url/' }

Example of a Catalyst action to handle the image:

sub image : Local {
    my ( $self, $c ) = @_;
    my $captcha = $c->session->{captcha};
    $c->response->body($captcha->{image});
    $c->response->content_type('image/'. $captcha->{type});
    $c->res->headers->expires( time() );
    $c->res->headers->header( 'Last-Modified' => HTTP::Date::time2str );
    $c->res->headers->header( 'Pragma'        => 'no-cache' );
    $c->res->headers->header( 'Cache-Control' => 'no-cache' );
}

πŸ‘‘ AUTHOR πŸ‘‘

FormHandler Contributors - see HTML::FormHandler. That's the squad. 🫢


This software is copyright (c) 2017 by Gerda Shank. πŸ’–

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Periodt. 🌈


πŸ’Œ Sign-off time: this is the HTML::...aptcha(3pm) page from perl v5.34.0, dated 2022-03-25. Bye bestie, go generate and validate those captchas. πŸ¦‹

πŸ“¦ where this page comes from