[ic] Addition of CookieExpire

Davor Ocelic docelic at spinlocksolutions.com
Tue Jun 24 17:18:56 UTC 2008


Hey folks,

Sites like Amazon etc. support 'resuming' your session even after you
close the browser.

Here's a simple patch that would add this functionality to Interchange.

When you set the new CookieExpire directive in the config file, then session
cookies are created with expiration date = time() + CookieExpire, instead
of at the end of session.

This allows you to 'resume' your session in that timeframe. As the date in
the cookie is not updated after initial cookie creation, the session *would*
eventually expire (in  time() + SessionExpire  after session creation).

Please comment.

-doc


diff -ruNP cvs-head/lib/Vend/Config.pm cvs-head,cookieExpire/lib/Vend/Config.pm
--- cvs-head/lib/Vend/Config.pm	2008-05-01 02:01:38.000000000 +0200
+++ cvs-head,cookieExpire/lib/Vend/Config.pm	2008-05-05 14:45:13.000000000 +0200
@@ -647,6 +647,7 @@
 	['WideOpen',		 'yesno',     	     'No'],
 	['Promiscuous',		 'yesno',     	     'No'],
 	['Cookies',			 'yesno',     	     'Yes'],
+	['CookieExpire',       'time',             '30 days'],
 	['CookieName',		 undef,     	     ''],
 	['CookiePattern',	 'regex',     	     '[-\w:.]+'],
 	['CookieLogin',      'yesno',            'No'],
diff -ruNP cvs-head/lib/Vend/Server.pm cvs-head,cookieExpire/lib/Vend/Server.pm
--- cvs-head/lib/Vend/Server.pm	2008-05-01 02:01:38.000000000 +0200
+++ cvs-head,cookieExpire/lib/Vend/Server.pm	2008-05-05 14:46:33.000000000 +0200
@@ -491,7 +491,7 @@
 	push @jar, [
 				($::Instance->{CookieName} || 'MV_SESSION_ID'),
 				defined $::Instance->{ClearCookie} ? '' : $Vend::SessionName,
-				$Vend::Expire || undef,
+				$Vend::Cfg->{CookieExpire} || $Vend::Expire || undef,
 			]
 		unless $Vend::CookieID;
 	push @jar, @{$::Instance->{Cookies}}
@@ -515,10 +515,12 @@
 			elsif($expire =~ /\s\S+\s/) {
 				$expstring = $expire;
 			}
-			$expstring = strftime "%a, %d-%b-%Y %H:%M:%S GMT ", gmtime($expire)
+			$expstring = strftime "%a, %d-%b-%Y %H:%M:%S GMT ", gmtime(time() + $expire)
 				unless $expstring;
 			$expstring = "expires=$expstring" if $expstring !~ /^\s*expires=/i;
 			$expstring =~ s/^\s*/ /;
+			$expstring =~ s/\s*$//;
+			$expstring .= ';' unless $expstring =~ /;$/;
 			$out .= $expstring;
 		}
 		$out .= "\r\n";



More information about the interchange-users mailing list