Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use Mojolicious::Lite;
- # Documentation browser under "/perldoc"
- plugin 'PODRenderer';
- get '/' => sub {
- my $self = shift;
- my $value = $self->cookie('foo');
- $value++;
- $self->stash( value => $value );
- $self->cookie('foo' => $value );
- if ( $value > 3 ) {
- $self->cookie('foo', { expires => time - 1 } );
- }
- $self->render('index');
- };
- app->start;
- __DATA__
- @@ index.html.ep
- % layout 'default';
- % title 'Welcome';
- Welcome to the Mojolicious real-time web framework!
- Cookie Value <%= $value %>
- @@ layouts/default.html.ep
- <!DOCTYPE html>
- <html>
- <head><title><%= title %></title></head>
- <body><%= content %></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement