Skip Menu |

This queue is for tickets about the CGI-Session CPAN distribution.

Report information
The Basics
Id: 13284
Status: resolved
Priority: 0/
Queue: CGI-Session

People
Owner: MARKSTOS [...] cpan.org
Requestors: MARKSTOS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 4.00_08
Fixed in: (no value)



Subject: is_new() missing in 4.x
The is_new() method which was present in CGI::Session 3.95 is broken in 4.00_08 (due to being missing).
Subject: is_new() missing in 4.x (patch to fix)
From: markstos [...] cpan.org
[guest - Thu Jun 16 21:01:44 2005]: Show quoted text
> The is_new() method which was present in CGI::Session 3.95 is broken > in 4.00_08 (due to being missing).
Attached is a complete patch to fix this, including code, docs and test. However it expects the Perl files to be in ./lib, which I have done in my tree. I've found it's very helpful to have the .pm files in a normal directory layout. This allows me to 'use' the files in a normal way, such as using 'prove' to run a single test script: prove -v -I./lib t/is_new.t I hope you'll consider that change to the distribution as well, as I plan to submit several more patches as well! Mark
Sun Jul 3 18:49:28 EST 2005 Mark Stosberg <mark@summersault.com> * Adding docs, tests and code for is_new(), a regression from 3.95 diff -rN -u old-cgi-session/Changes new-cgi-session/Changes --- old-cgi-session/Changes 2005-07-03 22:53:46.000000000 -0500 +++ new-cgi-session/Changes 2005-07-03 22:53:46.000000000 -0500 @@ -1,6 +1,8 @@ CGI::Session Change Log ===================================================================== + * FIX: Added back is_new() for compatibility with 3.95. (Mark Stosberg) + 4.00_08 - Tuesday, March 15, 2005 * FIX: Changes made in 4.00_07 rolled back diff -rN -u old-cgi-session/lib/CGI/Session.pm new-cgi-session/lib/CGI/Session.pm --- old-cgi-session/lib/CGI/Session.pm 2005-07-03 22:53:46.000000000 -0500 +++ new-cgi-session/lib/CGI/Session.pm 2005-07-03 18:44:18.000000000 -0500 @@ -210,6 +210,8 @@ sub is_expired { $_[0]->_test_status( STATUS_EXPIRED ) } +sub is_new { $_[0]->_test_status( STATUS_NEW ) } + sub id { return defined($_[0]->dataref) ? $_[0]->dataref->{_SESSION_ID} : undef } sub atime { return defined($_[0]->dataref) ? $_[0]->dataref->{_SESSION_ATIME} : undef } @@ -870,6 +872,10 @@ B<Note:> all the expiration times are relative to session's last access time, not to its creation time. To expire a session immediately, call L<delete()|/"delete">. To expire a specific session parameter immediately, call L<clear([$name])|/"clear">. +=item is_new() + +Returns true only for a brand new session. + =item is_expired() Tests whether session initialized using L<load()|/"load"> is to be expired. This method works only on sessions initialized diff -rN -u old-cgi-session/t/is_new.t new-cgi-session/t/is_new.t --- old-cgi-session/t/is_new.t 1969-12-31 19:00:00.000000000 -0500 +++ new-cgi-session/t/is_new.t 2005-07-03 18:48:10.000000000 -0500 @@ -0,0 +1,20 @@ +use Test::More qw/no_plan/; +BEGIN { use_ok ('CGI::Session') }; + +my $ses = new CGI::Session(); + +eval { $ses->is_new() }; +is ($@,'', "session has is_new() method"); + +ok( $ses->is_new(), "a brand new session is_new" ); + +my $ses_id = $ses->id(); + +my $ses2 = CGI::Session->load($ses_id); + +ok( ! $ses2->is_new(), "a session that has been closed and re-opened is not new"); + + + + +