Please bottom post...
B. Fongo wrote:
The error occurs on initial call, so id should be empty be then. I
expect the routine to open a new session (see code below) if session_id
is empty - but it fails then.
==
my $dbh = dbConnect();
# Get value of url or cookie id if any.
my $session_id = cookie(session); #|| param(session);
my ($cookie, $session_ref);
if (defined($session_id)){
$session_ref = Store::Session-new ($dbh, $session_id);
defined ($session_ref) || die (Couldn't retrieve session :);
} else {
$session_ref = Store::Session-new ($dbh, undef);
defined ($session_ref) || die (Couldn't start a new session:);
$cookie = cookie (-name = session,
-value = $session_ref,
-expires = +3d,
-domain = .shop.com
);
}
print header (-cookie = $cookie);
start_html();
print p (The session id is : $session_ref);#See the value of ref
here.
end_html();
==
Those Apache::Session docs aren't of good help to me in this matter.
I assume you have double and triple checked that $session_id is in fact
undefined. And that your code above will always die (unless you fixed
the issue with the 'return' noted before) because $session_ref will
always be undefined.
You might consider moving your header print to before the session
constructor call, and hacking in some debugging code into the failing
module. Have it print the value of the session id at that time,
$session-{data}-{_session_id}
Can you provide versions for Perl, Apache::Session, is this running
under mod_perl?
Baffled
http://danconia.org
My implementation of Apache::Session::MySQL dies along the way, and
gives
unclear warning.
[error] Died at
/usr/lib/perl5/site_perl/5.8.0/Apache/Session/Generate/MD5.pm
line 40.
I decided to implement session as a module call Store::Session, so as
to
minimize recoding it in many script.
Babs
What does your session id have in it? Is this error produced on the
initial construction of the session (aka first request) or on subsequent
requests? It appears that the error you are receiving is because the
session id is either empty or contains a non-alphanumeric character.
Try printing the session id before calling the constructor to see if
there is something in it that shouldn't be
[snip comments we don't need]
package Store::Session;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(new getId closeSession deleteObject);
use strict;
use Apache::Session::MySQL;
sub new {
my ($dbh, $session_id) = @_;
my %session;
tie %session, Apache::Session::MySQL, $session_id,{
Handle = $dbh, LockHandle = $dbh
};
return;#(\%session);
Why do you have the session reference commented out, your %session goes
out of scope immediately following this method and no longer has any
referents so will no longer be available, which could be part of your
problem. You may want to just remove the 'return' completely as 'tie'
will return the referent, and assuming there is nothing after your 'tie'
then it will be the last expression in the sub and will be returned
automagically.
See if that helps, if not come back...
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response