The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Gantry::Plugins::CookieCheck - Plugin to test that cookies are enabled.

SYNOPSIS

Plugin must be included in the Applications use statment.

    <Perl>
        use MyApp qw{
                -Engine=CGI
                -TemplateEngine=TT
                -PluginNamespace=your_module_name
                CookieCheck
        };
    </Perl>

Bigtop:

    config {
        engine MP20;
        template_engine TT;
        plugins CookieCheck;
        ...

There are various config options.

Apache Conf:

    <Location /controller>
        PerlSetVar cc_title Title
        PerlSetVar cc_wrapper default.tt
        PerlSetVar cc_template cc_template.tt
        PerlSetVar cc_secret zak7mubuS9SpUraTHucUXePhAdR4meFUhAmAChEjAPuGUBrakeVenuvu
    </Location>

Gantry Conf:

    cc_title Title
    cc_wrapper default.tt
    cc_template cc_template.tt
    cc_secret zak7mubuS9SpUraTHucUXePhAdR4meFUhAmAChEjAPuGUBrakeVenuvu
    cc_domain my.domain.com
    cc_exclude /regex/path/to/exclude

DESCRIPTION

This module is based on the cookie check code that was originally part of the Gantry::Plugins::Session module. It will check if cookies are enabled by setting a test cookie called acceptcookies and then redirect the user to a method called do_cookiecheck that will verify the cookie exists. This module works best when -StateMachine=Exceptions is used since that will allow the redirect to take place right away instead of waiting till the entire request has been processed.

CONFIGURATION

The following items can be set by configuration:

 cc_title       a title for the session template
 cc_wrapper     the wrapper for the session template
 cc_template    the template for missing cookies notice
 cc_secret      key used to encrypt url string during redirection
 cc_domain      domain used for test cookie
 cc_exclude     regular expression of locations to exclude from the
                cookie check.

The following reasonable defaults are being used for those items:

 cc_title       "Missing Cookies"
 cc_wrapper     template_wrapper from configuration or default.tt
 cc_template    cc.tt
 cc_secret      the value specified for gantry_secret
 cc_domain      empty.
 cc_exclude     all locations are checked

METHODS

get_callbacks
  get_callbacks($namespace)

Register the set_test_cookie callback for the init phase.

do_cookiecheck
  do_cookiecheck()

This method verifies the acceptcookies cookie was set and redirects the user back to the originally requested url. If the acceptcookies cookie is missing the user is given an error page telling them they need to enable cookies in their web browser.

  set_test_cookie()

This method checks for the existence of the acceptcookies cookie. If it is not found then it sets the cookie and redirects the user to the do_cookiecheck method.

SEE ALSO

    Gantry
    Gantry::Utils::Crypt

AUTHOR

John Weigel <jweigel@sunflowerbroadband.com>

COPYRIGHT AND LICENSE

Copyright (C) 2009 The World Company

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.