[Cgi-session-user] V 4.03: Problem with load(), delete() and flush()
Brought to you by:
sherzodr
From: Ron S. <ro...@sa...> - 2006-01-12 04:30:14
|
Hi Folks It seems to me that there is a problem here. Code is at the end. Line numbers refer to Session.pm. Flow of control in the code: o I create a session, defaulting to type file o I capture the id o I call load($id) in a new scope o load($id) sets up: =09- $$self{_DATA}{_SESSION_ID} as undef @ line 579 =09- $$self{_CLAIMED_ID'} as $id @ line 603 o I call $session -> id() which returns undef: =09- This may be deliberate design decision, but... =09- This is the first indication of a problem o I call delete() which is loitering with intent @ line 279 o The program exits, which causes DESTROY() @ line 67 to be called o This causes flush() @ line 179 to be called o But look at line 182: return unless $self->id; # <-- empty session Since id() returns undef I can never delete the session via line 194: defined($driver->remove($self->id)) or -----><8----- #!/usr/bin/perl # # Name: #=09test-flush.pl. # # Note: #=09\t =3D 4 spaces || die. use strict; use warnings; use CGI::Session; # --------------- my($dir_name) =3D 'c:/temp'; chdir($dir_name) || die "Can't chdir($dir_name): $!"; my($id); my($session); { =09$session=09=3D CGI::Session -> new(); =09$id=09=09=09=3D $session -> id(); =09print "Inner scope. New session: $session. id: $id. \n"; } print "Original scope. id: $id. \n"; $session =3D CGI::Session -> load($id); print "Original scope. Old session: $session. id: ", $session -> id(), ".= \n"; if ($session -> is_empty() ) { =09print "Original scope. Empty. \n"; =09$session -> delete(); } -----><8----- -- Cheers Ron Savage, ro...@sa... on 12/01/2006 http://savage.net.au/index.html Let the record show: Microsoft is not an Australian company |