Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Answer: Cookies and Exec Cgi

by rob_au (Abbot)
on Dec 27, 2001 at 06:04 UTC ( #134537=note: print w/replies, xml ) Need Help??

in reply to Cookies and Exec Cgi

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&&[@.]/&&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...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://134537]
[choroba]: The previous line tells it all.
[choroba]: "Out of memory!" - anything can happen afterwards
[Discipulus]: my father sometimes gives the same result.. good fellow

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2018-02-21 13:59 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (280 votes). Check out past polls.