On my previous posts we saw how to to create and use true global variables. Their usage is limited to $dbh at the moment. But I also need a “global” variable, shared between all components of the same request. Here’s one of my first tries, and this is how the Base.mc will look like:

has 'title';
has 'authenticated_user';

<%augment wrap>
 <link rel="stylesheet" href="/static/css/style.css">
% $.Defer {{
 <title><% $.title %></title>
% }}
 <% inner() %>

and this is the index.mc:

Welcome, <% $.authenticated_user %>
$.title("Welcome to Sentosa");

I think I will use Base.mp and here’s what I’m going to do:

has 'authenticated_user';
has 'title';

method wrap() {
 $.authenticated_user ("Superuser");

Next, how do I actually authenticate my users? See it on my next post!