Set a passphrase for signed cookies

Set a passphrase for signed cookies Use the secrets method of the Mojolicious class to set it. Pass an array reference as an argument.

$app->secrets(['lkjsdf%$#']);

If you do not make this setting, a warning will be issued, so set it in a non-test environment.

This is an example of use with Mojolicious::Lite and Mojolicious.

#Mojolicious::Lite
app->secrets(['lkjsdf%$#']);

#Mojolicious
sub starup {
  my $self = shift;
  $self->secrets(['lkjsdf%$#']);
}

Set a new passphrase without interrupting the session.

You can set a new passphrase without interrupting your session.

$app->secrets(['new_passw0rd','old_passw0rd']);

Please set a new passphrase at the beginning.

Changes in Mojolicious 5

The secret method has been deprecated and replaced by the secrets method. This is to set a new passphrase to avoid discarding the session.

Associated Information