Tags:
create new tag
, view all tags

Feature Proposal: Add counter to session variables

Motivation

Sometimes it is desirable to take some action on the very first page view after a login, such as to show a help dialog box. This is possible if we add a counter to the session variables where we can query how many pages have been viewed with the current session after login.

Description and Documentation

Add a SESSION_REQUEST_NUMBER session variable that can be queried using %SESSIONVARIABLE{SESSION_REQUEST_NUMBER}%. On first page view after login it is set to 1, next page view is 2, etc.

Examples

Impact

Implementation

--- lib/TWiki/LoginManager.pm.save1   2010-10-11 06:15:40.000000000 +0000
+++ lib/TWiki/LoginManager.pm   2011-03-31 19:32:39.000000000 +0000
@@ -512,6 +512,7 @@
                   undef, $twiki->{request},
                   { Directory => "$TWiki::cfg{WorkingDir}/tmp" } );
             die TWiki::LoginManager::Session->errstr() unless $this->{_cgisession};
+            $this->{_cgisession}->param( 'SESSION_REQUEST_NUMBER', 0 );
         }
     }
     if( $authUser && $authUser ne $TWiki::cfg{DefaultUserLogin} ) {
@@ -527,13 +528,17 @@
             # TODO: these are bare login's, so if and when there are multiple usermappings, 
             # this would need to include cUID..     
             $this->{_cgisession}->param( 'AUTHUSER', $authUser );
+            my $num = ( $this->{_cgisession}->param( 'SESSION_REQUEST_NUMBER' ) || 0 ) + 1;
+            $this->{_cgisession}->param( 'SESSION_REQUEST_NUMBER', $num );
         }
         $twiki->enterContext( 'authenticated' );
     } else {
         _trace( $this, "Session is NOT authenticated" );
         # if we are not authenticated, expire any existing session
-        $this->{_cgisession}->clear( [ 'AUTHUSER' ] )
-          if( $TWiki::cfg{UseClientSessions} );
+        if( $TWiki::cfg{UseClientSessions} ) {
+            $this->{_cgisession}->clear( [ 'AUTHUSER' ] );
+            $this->{_cgisession}->param( 'SESSION_REQUEST_NUMBER', 0 );
+        }
         $twiki->leaveContext( 'authenticated' );
     }
     if( $TWiki::cfg{UseClientSessions} ) {

-- Contributors: PeterThoeny - 2011-03-31

Discussion

This is now accepted by 7 days feedback period.

-- PeterThoeny - 2011-04-08

This is now implemented in SVN trunk and documented.

-- PeterThoeny - 2011-04-09

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2011-04-09 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.