On 4/26/06, Anthony Chee <[EMAIL PROTECTED]> wrote: > I did not use cookie in my application
CGI::Application::Plugin::Session uses cookies by default, and does so
automatically, so since you don't shw any configuration that turned
off the cookie support, I assumed you must be using cookies.
> I know that there are new() and load() method in CGI::Session. To check
> whether the session is expired, first use load() to load the existing
> session and use is_expired() to check whether the session is expired. It
> seems that CGI::Application::Plugin::Session only use new(), a new session
> will be created automatically when there is no session before or the session
> is expired.
a call to $self->session has to return a valid usable session. If it
didn't, then you would have to put code like this throughout your
CGI::Application code:
my $session = $self->session;
if ($session->is_empty) {
# handle empty session
} else {
# use the session
}
So using 'load' is not an option. The only useful scenario I see for
using 'load' is when you want to check to see if a session is there
without actually creating a session. To use it to check to see if a
session is expired seems akward and annoying (that is not blaming your
use, but blaming CGI::Session for an annoying interface).
However, I ran some tests, and it looks like 'load' is not needed to
detect expired sessions. Since 'new' actually calls 'load'
internally, the 'is_expired' flag will be set even when calling 'new'.
So really the CGI::Session docs should be clarified with the example
it gives for detecting expired sessions.
I have attached a program that tests the different scenarios, and here
is the output:
No Session ID passed in:
7b4692ecd080a72c70f8b347eedb8718 new Yes
7b4692ecd080a72c70f8b347eedb8718 expired No
Valid Session ID passed in and session is in the store:
7b4692ecd080a72c70f8b347eedb8718 new No
7b4692ecd080a72c70f8b347eedb8718 expired No
Valid Session ID passed in and session is in the store, but session has expired:
5cbab661beddf73521712eae16dd7e6e new Yes
5cbab661beddf73521712eae16dd7e6e expired Yes
Valid Session ID passed but session not in the store:
7392ed0df216591b35e35183ed33dc23 new Yes
7392ed0df216591b35e35183ed33dc23 expired No
To me that should be enough information to display a 'Your session has
been expired' message.
Cheers,
Cees
session.pl
Description: Perl program
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
