in reply to Re: Persistent login session with restricted access
in thread Persistent login session with restricted access
A Perl approach to this type of thing (which I believe is what the OP requested) would probably include the use of a templating system. Template (the Template Tooklit) is one good choice. In that case your first line of code would appear in the main part of the script as:
$args->{logged_in} = some_boolean_expression;where $args is the hash containing the arguments for Template's process method. Then in the template you'd have
[% IF logged_in %] some stuff here [% END %]
If the "some stuff here" were very large, and you find enormous IF blocks distasteful (which many do), then you could instead have
[% IF logged_in %] [% PROCESS stuff %] [% END %]
where "stuff" is the name of another template that contains only the things that should appear if the user is logged in. This is a good solution where you have a substantial amount of content to show only for logged in users, and a substantial amount of content for either situaion.
If, OTOH, the page you want the user to see is completely different depending on whether they're logged in or not, you don't need a condition in your template at all. In that case, simply have your script invoke a different template altogether, depending on the status.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Persistent login session with restricted access
by kgish (Acolyte) on Oct 10, 2004 at 12:51 UTC |