Load XDB to workaround a segfault in PHP.
[platal.git] / classes / env.php
index 5b6a2b9..cecee84 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2010 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -217,11 +217,14 @@ class Cookie
         unset($_COOKIE[$key]);
     }
 
-    public static function set($key, $value, $days) {
+    public static function set($key, $value, $days, $secure = false) {
         global $globals;
         $key = $globals->cookie_ns . $key;
-        setcookie($key, $value, time() + 86400 * $days, $globals->cookie_path);
-        $_COOKIE[$key] = $value;
+        if (!$secure || @$_SERVER['HTTPS']) {
+            setcookie($key, $value, time() + 86400 * $days, $globals->cookie_path, '',
+                      $secure, $secure);
+            $_COOKIE[$key] = $value;
+        }
     }
 
     public static function v($key, $default = null)