Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
This has not been my experience Merlyn - Well, from the point of view of detecting cookies within server-side includes.

I have a web site under construction that makes use of a cookie-based session system via by server side includes. For example, the index.shtml file calls a 'links' sidebar where authenticated users can set their own personal bookmark links, much like the personal nodelet on this site, whereas non-authenticated users are displayed a login form.

The index.shtml server-side include looks like this:

<!--#include virtual="/cgi-bin/links.cgi" -->

Where the corresponding display_links dispatch subroutine of the links.cgi code, which uses CGI::Application, looks similar to this (cut a little for brevity):

sub display_links { my $self = shift; my $cgi = $self->query; my $xml = $self->param('xml'); my %auth = $cgi->cookie( -name => 'cowsnet-auth', -path => '/' ); my $html; if (scalar keys %auth) { my $prefs = eval { my @user = grep { $_->{'username'} eq $auth{'username'} } +@{%{$xml}->{'user'}}; return shift @user; }; $html = $self->load_tmpl("authenticated.tmpl"); if (exists $prefs->{'links'}) { my @links; push (@links, { 'href' => eval { my $uri = URI->new($_->{'href'}); $uri->canonical->as_string; } }) foreach @{$prefs->{'links'}}; $html->param( 'links' => \@links ); } } else { $html = $self->load_tmpl("default.tmpl"); } return $html->output; }

This works like a charm - In order to set cookies with this system however I do still resort to calling a CGI directly which redirects through to 'authentication' page.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

20060730 Unconsidered by Corion: Consideration impossible. Was considered by jdporter: reparent to its proper parent, Answer: Cookies and Exec Cgi. Not sure how it ended up in the wrong place...


In reply to Re: Answer: Cookies and Exec Cgi by rob_au
in thread Cookies and Exec Cgi by ThingFish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (7)
    As of 2014-11-25 01:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (148 votes), past polls