# Create empty session # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", undef, {FileName=>"/tmp/sessions/test/"}; print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d' }; # Open that session for preliminary testing # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"}; print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d' }; # Add simple scalar data to session # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"}; $s{t} = 1; print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d', 't' => 1 }; # Re-open session to check for added data # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"};print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d', 't' => 1 }; # Start on our AoH # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"}; $s{m} = [{one => 1}]; print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d', 'm' => [ { 'one' => 1 } ], 't' => 1 }; # Add another entry to our AoH. Notice that Dumper # says it's there before we untie(). # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"}; push @{$s{m}}, {two=>2}; print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d', 'm' => [ { 'one' => 1 }, { 'two' => 2 } ], 't' => 1 }; # Get back the session. Notice that the second entry # in the AoH is missing. # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"};print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d', 'm' => [ { 'one' => 1 } ], 't' => 1 }; # Work-around--create a dummy parameter which forces # Apache::Session to realize that the data has changed. # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"}; push@{$s{m}}, {two => 2}; $s{dummy} = 1; print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d', 'dummy' => 1, 'm' => [ { 'one' => 1 }, { 'two' => 2 } ], 't' => 1 }; # Re-open session to check for new data. Notice that # the AoH was saved properly due to the dummy param. # $ perl -MApache::Session::File -MData::Dumper=Dumper -e 'tie %s, "Apache::Session::File", "41b4260f41720aed6b24e802a41ad57d", {FileName=>"/tmp/sessions/test/"}; print Dumper(\%s); untie %s;' $VAR1 = { '_session_id' => '41b4260f41720aed6b24e802a41ad57d', 'm' => [ { 'one' => 1 }, { 'two' => 2 } ], 'dummy' => 1, 't' => 1 };