in reply to Re: CGI::Session/MySQL dependancy/version woes
in thread CGI::Session/MySQL dependancy/version woes
Thanks for your response.
tmpl/session.html#!/usr/bin/perl #!c:\Perl\bin\perl.exe use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use lib qw(/path/to/lib_dev); use CGI::Simple; use CGI::Session; # v4.13 (was v3.11) use HTML::Template; use DBI; # v1.32 my $q = CGI::Simple->new() or die "can't create query object: $!"; my $dbh = DBI->connect('DBI:mysql:database=mydb;host=myhost', 'myuid', + 'mypwd') or die "can't connect to db"; my $sid = $q->cookie("CGISESSID") or undef; my $s = CGI::Session->new(undef, $sid, {Handle => $dbh}) or die CGI::Session->errstr; # corrected $_ = $q->param('a'); if (/next/) { next_page() } elsif (/prev/) { previous_page() } else { first_page() } sub next_page { my $first = $s->param('f'); $first += 20; $s->param('f', $first); print_output($first); } sub previous_page { my $first = $s->param('f'); $first -= 20; $s->param('f' => $first); print_output($first); } sub first_page{ $s->param('f', 0); print_output(0); } sub print_output { my ($first) = @_; my $file = 'tmpl/session.html'; my $t = HTML::Template->new( filename => $file ) or die "can't find $file: $!"; $t->param({first => $first}); print $s->header; print $t->output; }
<html> <head> <title>sessions</title> </head> <body> <a href="/z/session.cgi?a=prev">previous</a> <a href="/z/session.cgi?a=next">next</a> <p><TMPL_VAR NAME=first></p> </body> </html>
UpdateResponse Headers - http://www.somedomain.org.uk/z/session.cgi?a=next Server: Zeus/4.2 Date: Sun, 17 Sep 2006 06:46:36 GMT Set-Cookie: CGISESSID=a26c68329dbf87f6e5d69ff416ab1314; path=/ Content-Type: text/html; charset=ISO-8859-1 Transfer-Encoding: chunked 200 OK
Adding:
to the next_page sub produces:die Dumper $s;
Update 2Software error: $VAR1 = bless( { '_API_3' => { 'ID' => 'MD5', 'SERIALIZER' => 'Default', 'DRIVER' => 'File' }, '_STATUS' => 1, '_file_path' => '/cgisess_d71ef41aa899089fdf39190ea38 +0d10e', '_DATA' => { '_SESSION_ETIME' => undef, '_SESSION_ID' => '86c76f868575c30ccd29e3 +ebb7ca3c03', '_SESSION_ATIME' => 1158477726, '_SESSION_EXPIRE_LIST' => {}, '_SESSION_REMOTE_ADDR' => '86.139.50.197 +', '_SESSION_CTIME' => 1158477726 }, '_OPTIONS' => [ 'd71ef41aa899089fdf39190ea380d10e', { 'Handle' => bless( {}, 'DBI::db' ) } ] }, 'CGI::Session::File' );
After uploading Session.pm (see comment re version) and the Session dir:
After removing the die statementSoftware error: $VAR1 = bless( { '_STATUS' => 1, '_OBJECTS' => { 'id' => 'CGI::Session::ID::md5', 'driver' => bless( { 'Directory' => ' +/tmp', 'NoFlock' => 0, 'UMask' => 432, 'Handle' => bles +s( {}, 'DBI::db' ) }, 'CGI::Session:: +Driver::file' ) }, '_CLAIMED_ID' => 'd71ef41aa899089fdf39190ea380d10e', '_DATA' => { '_SESSION_ID' => 'cf417d8baa05dfe64bcc53 +088b736740', '_SESSION_ATIME' => 1158478795, '_SESSION_REMOTE_ADDR' => '86.139.50.197 +', '_SESSION_CTIME' => 1158478795 }, '_QUERY' => undef, '_DRIVER_ARGS' => $VAR1->{'_OBJECTS'}{'driver'}, '_DSN' => { 'serializer' => 'default', 'id' => 'md5', 'driver' => 'file' } }, 'CGI::Session' );
Scalar::Util is there (v1.18) and it contains sub refaddr.Undefined subroutine &Scalar::Util::refaddr called at /xxx/lib_dev/CGI +/Session/Serialize/default.pm line 53.
|
|---|