Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI::Cookie w/ Mason

Status
Not open for further replies.

Wolfie7873

Technical User
Jan 15, 2004
94
US
Trying to do some session management. Have this:
Code:
{  package HTML::Mason::Commands;
   use vars qw(%session);
   use CGI::Cookie;
   use Apache::DBI;
   use Apache::Session::MySQL;
}

# Get the incoming cookies
my %cookies = CGI::Cookie->fetch or die "could not fetch CGI::Cookie";

# Try to re-establish an existing session
eval {
    tie %HTML::Mason::Commands::session, 'Apache::Session::MySQL',
       ($cookies{'AF_SID'} ? $cookies{'AF_SID'}->value() : undef),
        {
           DataSource => $dsn,
           UserName => $user,
           Password => $pwd
        } or die "could not tie existing session" . $!;
     };

# If we could not re-establish an existing
# session, create a new session.

if ( $@ ) {
    print "there was an error" . $@;
   if ( $@ =~ m#^Object does not exist in the data store# )  {
       tie %HTML::Mason::Commands::session,
           'Apache::Session::MySQL',
            undef,
           {
              DataSource => $dsn,
              UserName => $user,
              Password => $pwd
          };
       undef $cookies{'AF_SID'} or die "could not tie new session" . $!;
    }
}

if ( !$cookies{'AF_SID'} )   {
   my $cookie = CGI::Cookie->new($r,
     -name => 'AF_SID',
     -value => $HTML::Mason::Commands::session{_session_id},
     -path => '/',
     -domain => 'tarheeloesrescue.org',
     );

    $cookie->bake or die "could not bake cookie" . $!;
}
my $session = \%session;
Currently, this dies at the first if block with:
Code:
Died at /var/[URL unfurl="true"]www/html/lib/Apache/Session/Generate/MD5.pm[/URL] line 40. 
Stack: 
[/var/www/html/lib/Apache/Session/Generate/MD5.pm:40] 
[/var/www/html/lib/Apache/Session.pm:414]
[/var/www/subdomains/test/html/autohandler:139]

Any clues? I've been through Apache::Cookie, Apache2::Cookie and haven't had ANY success writing a freaking cookie yet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top