這裏是從lib文件夾中的myapp模塊:如何在Catalyst應用程序中初始化會話?
package myapp;
use Moose;
use namespace::autoclean;
use Catalyst::Runtime 5.80;
use Catalyst qw/
ConfigLoader
Session
Session::Store
Session::State
Static::Simple
/;
extends 'Catalyst';
our $VERSION = '0.01';
__PACKAGE__->config(
name => 'myapp',
# Disable deprecated behavior needed by old applications
disable_component_resolution_regex_fallback => 1,
enable_catalyst_header => 1, # Send X-Catalyst header
);
sub init {
my ($c) = @_;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
$c->session->{ed_year} = $year + 1900;
}
# Start the application
__PACKAGE__->setup();
__PACKAGE__->init();
1;
上面的例子是錯誤的,沒有可用的情況下($ C)。我想知道是否可以在其主模塊中的Catalyst應用程序中初始化會話。在這裏,我想初始化全局變量,稍後由視圖,模型和控制器使用?
此致 SK