untie %session;I made two calls to ties for a test and the server comsume alot of CPU and never return. So I don't know what is going on.
... print "Content-type: text/html\n\n"; tie %session, 'Apache::Session::File', undef; $sessId = $session{_session_id}; print "id: " . $sessId . "\n";
or
undef %session;
Apache session using locking mechanism so when you have touched session it's locked until you end up with it.
Yes, pass to user, but there more ways then just Cookie.
#the prog get hung when I added this line tie %session, 'Apache::Session::File', $sessId; $sessId = $session{_session_id}; print "id: " . $sessId . "\n"; ...
In any case, are you saying that I have to pass the sessionId to the client as a cookie as in the doc?
If so, isn;t there a package that already wraps this up for me?
Use next scheme for start: my %cookies = CGI::Cookie->fetch(); $sid = ($cookies{'SID'} ? $cookies{'SID'}->value() : undef ); eval { tie %session, 'Apache::Session:: ... ', $sid, {}; }; if ($@) {
# If the session is invalid, create a new session. if ( $@ =~ /Object does not/i ) { tie %session, 'Apache::Session:: ... ', undef, {}; undef $cookies{'SID'}; } else { die "[EMAIL PROTECTED] Check that this directory's permissions are correct."; } } if ( !$cookies{'SID'} ) { my $cookie = new CGI::Cookie( -name => 'SID', -value => $session{_session_id}, -path => '/', ); $r->header_out('Set-Cookie', $cookie->as_string); }
thanks
Hello. Have you read `perldoc Apache::Session`? There is two examples.
[EMAIL PROTECTED] wrote:
I'm getting a new id with every refresh click; so, how am I suppose to know it is the same session? Here's my code:
#!/usr/bin/perl use Apache::Session::File; use strict; use warnings;
my %session; my $sessId;
#I'm suppose to put the session id at the undef #but how am i suppose to #know what it is the next time around? #tie %session, 'Apache::Session::File', undef, # { Directory => '/tmp', LockDirectory =>'/tmp' };
tie %session, 'Apache::Session::File';
What about third argument??? It have to be session_id if you wnat old one or undef if you want new. So you have to store session_id somewhere on the client side!
$sessId = $session{_session_id}; print "Content-type: text/html\n\n"; print "id: " . $sessId . "\n";
...
What am I doing wrong?
thanks