Revision 264

Date:
2013/01/15 14:20:08
Author:
ahitrov
Revision Log:
Bug: get_session during first user request creates excess table record
Bug: store_value after get_session during first user request creates excess session

Files:

Legend:

 
Added
 
Removed
 
Modified
  • koi8/plugins/session/lib/session/Keeper.pm

     
    114 114
    115 115 sub get_value {
    116 116
    117 my ($self, $name) = @_;
    118 my $sid = _get_session_id ();
    117 my ($self, $name, %opts) = @_;
    118 my $sid = delete $opts{_session_id} || _get_session_id ();
    119 119 my $session = _get_session_object ( $sid );
    120 120 return unless ref $session;
    121 121
     
    133 133 sub store_value {
    134 134
    135 135 my ($self, %opts) = @_;
    136 my $sid = _get_session_id ();
    136 my $sid = delete $opts{_session_id} || _get_session_id ();
    137 137 my $session = _get_session_object ( $sid );
    138 138 return unless ref $session;
    139 139
     
    153 153
    154 154 sub delete_key {
    155 155
    156 my ($self, $key) = @_;
    156 my ($self, $key, %opts) = @_;
    157 157 return unless $key;
    158 158
    159 my $sid = _get_session_id ();
    159 my $sid = delete $opts{_session_id} || _get_session_id ();
    160 160 my $session = _get_session_object ( $sid );
    161 161 return unless ref $session;
    162 162
     
    253 253 if ($@) {
    254 254 warn "Session data is not accessible: $@";
    255 255 undef $sid;
    256 } elsif ( $state->{session}->lifetime ) {
    257 unless ( exists $session{_timestamp} ) {
    258 $session{_timestamp} = $now;
    259 } elsif ( ($now - $session{_timestamp}) > $state->{session}->lifetime ) {
    260 undef $sid;
    261 } elsif ( ($now - $session{_timestamp}) > $state->{session}->checkout ) {
    262 $session{_timestamp} = $now;
    256 } else {
    257 $sid = $session{_session_id};
    258 if ( $state->{session}->lifetime ) {
    259 unless ( exists $session{_timestamp} ) {
    260 $session{_timestamp} = $now;
    261 } elsif ( ($now - $session{_timestamp}) > $state->{session}->lifetime ) {
    262 undef $sid;
    263 } elsif ( ($now - $session{_timestamp}) > $state->{session}->checkout ) {
    264 $session{_timestamp} = $now;
    265 }
    263 266 }
    264 267 }
    265 268 unless ( $sid ) {