Subject: | flag for new session |
Sometimes I want my code to behave differently if the current hit is a new session instead of an old one. Currently, the only way to tell if a session is new is to compare the atime to the ctime. However, in testing (albeit an unrealistic case) if there are two hits inside of one second, the second looks like a new session based on my test, when it is not.
If _init_new_session added a property "_NEW_SESSION => 1", that would be enormously valuable for the creation of an isNewSession() method.
Below is a patch to implement this behavior. It is untested.
Chris Dolan
-----------------------------------------------------------------
diff -u Session.pm-orig Session.pm
--- Session.pm-orig 2003-03-13 13:00:31.000000000 -0600
+++ Session.pm 2003-03-13 13:01:53.000000000 -0600
@@ -301,12 +301,17 @@
};
$self->{_STATUS} = MODIFIED;
+ $self->{_NEW_SESSION} = 1;
return 1;
}
-
-
+sub isNewSession
+{
+ my $self = shift;
+
+ return $self->{_NEW_SESSION} ? 1 : 0;
+}
# id() - accessor method. Returns effective id
# for the current session. CGI::Session deals with