[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2842] trunk/LedgerSMB/Auth/DB.pm



Revision: 2842
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2842&view=rev
Author:   einhverfr
Date:     2010-01-22 21:46:22 +0000 (Fri, 22 Jan 2010)

Log Message:
-----------
Setting secure flag on cookie where appropriate

Modified Paths:
--------------
    trunk/LedgerSMB/Auth/DB.pm

Modified: trunk/LedgerSMB/Auth/DB.pm
===================================================================
--- trunk/LedgerSMB/Auth/DB.pm	2010-01-22 21:43:28 UTC (rev 2841)
+++ trunk/LedgerSMB/Auth/DB.pm	2010-01-22 21:46:22 UTC (rev 2842)
@@ -90,7 +90,10 @@
               $session_ref->{session_id} . ':' . $session_ref->{token} . ':' . $form->{company};
 
             #now update the cookie in the browser
-            print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=$newCookieValue; path=$path;\n|;
+            if ($ENV{SERVER_PORT} == 443){
+                 $secure = ' Secure;';
+            }
+            print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=$newCookieValue; path=$path;$secure\n|;
             return 1;
 
         }
@@ -101,7 +104,10 @@
             my $sessionDestroy = $dbh->prepare("");
 
             #delete the cookie in the browser
-            print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=; path=$path;\n|;
+            if ($ENV{SERVER_PORT} == 443){
+                 $secure = ' Secure;';
+            }
+            print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=; path=$path;$secure\n|;
             return 0;
         }
 
@@ -110,7 +116,10 @@
 
         #cookie is not valid
         #delete the cookie in the browser
-        print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=; path=$path;\n|;
+            if ($ENV{SERVER_PORT} == 443){
+                 $secure = ' Secure;';
+            }
+        print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=; path=$path;$secure\n|;
         return 0;
     }
 }
@@ -197,7 +206,10 @@
 
     #now set the cookie in the browser
     #TODO set domain from ENV, also set path to install path
-    print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=$newCookieValue; path=$path;\n|;
+    if ($ENV{SERVER_PORT} == 443){
+         $secure = ' Secure;';
+    }
+    print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=$newCookieValue; path=$path;$secure\n|;
     $lsmb->{LedgerSMB} = $newCookieValue;
     $lsmb->{dbh}->commit;
 }
@@ -265,7 +277,10 @@
         __FILE__ . ':' . __LINE__ . ': Delete from session: ' );
 
     #delete the cookie in the browser
-    print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=; path=$path;\n|;
+    if ($ENV{SERVER_PORT} == 443){
+         $secure = ' Secure;';
+    }
+    print qq|Set-Cookie: ${LedgerSMB::Sysconfig::cookie_name}=; path=$path;$secure\n|;
 
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.