deduplicate session cookies
authorAlan Knowles <alan@roojs.com>
Tue, 1 Sep 2020 07:23:57 +0000 (15:23 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 1 Sep 2020 07:23:57 +0000 (15:23 +0800)
HTML/FlexyFramework/Page.php
HTML/FlexyFramework2.php

index 4a5c810..9b2481f 100644 (file)
@@ -430,8 +430,31 @@ class HTML_FlexyFramework_Page  {
                 $ini = true;
                 // sometimes raises a notice - ps_files_cleanup_dir.
                 @session_start();
+                $this->dedupeSessionCookies();
                 return;
         }
     }
+    
+    function dedupeSessionCookies()
+    {
+         if (headers_sent()) {
+            return;
+        }
+        $cookies = array();
+        
+        foreach (headers_list() as $header) {
+            // Identify cookie headers
+            if (strpos($header, 'Set-Cookie:') === 0) {
+                $cookies[] = $header;
+            }
+        }
+        header_remove('Set-Cookie');
+
+        // Restore one copy of each cookie
+        foreach(array_unique($cookies) as $cookie) {
+            header($cookie, false);
+        }
+    }
+    
 
 }
index 808e450..fed11cd 100644 (file)
@@ -799,7 +799,7 @@ class HTML_FlexyFramework2 {
     {
         /* have I been initialized */
         
-        
+        /* 
         if (get_magic_quotes_gpc() && !$this->cli) {
             $this->fatalError(
                 "magic quotes is enabled add the line<BR>
@@ -809,6 +809,7 @@ class HTML_FlexyFramework2 {
                    ");
                 
         }
+        */
         // set up error handling - 
         //$this->error = new HTML_FlexyFramework2_Error();