I've been playing around with CGI::Session lately, I've run into a 'question'. I can easly work around this but I don't understand the behavour. Could someone please enlighten me?

It seems if I say

my $S = new CGI::Session(undef,undef,{Directory=>"$some_dir"});
in the setup method in my CGI::Application the sessions are created in $some_dir, Great.

But wait, If I make $S global to my application module (i.e. use vars qw/$S/;) the sessions get created in the C:\ directory. Windows perversions and why I would make this a global variable aside, the really peculiar thing (to me) is if I test this program with WWW::Mechinize the sessions get put in $some_dir.

What am I missing about sessions?

##### huh.pl #! Perl use lib 'C:\cgi-bin\Plot2'; use Plot2; Plot2->new()->run; ##### Plot2.pm #! Perl package Plot2; use warnings; use strict; use CGI::Session; use base qw/CGI::Application/; use vars qw/ $HOME $S/; $HOME = 'C:\cgi-bin\Plot2'; sub setup { my $self = shift; $S = new CGI::Session( undef,undef, {Directory => "$HOME/sessions"} ); my $cookie = $self->query->cookie( -name => $S->nane, -value => $S->id); $self->header_props( -cookie => $cookie ); $self->start_mode('page1'); $self->run_modes('page1' => 'page1' ); } sub page1 {'huh';} 1; #### t.pl ! Perl use warnings; use strict; use Test::More qw/no_plan/; use WWW::Mechanize; my $m = WWW::Mechanize->new(); $m->get( 'http://127.0.0.1/cgi-bin/huh.pl' ); like( $m->content(), qr/huh/, "Got expected login" );

In reply to CGI::Application & CGI::Session by Anonymous Monk

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.