fix redirect
[pharext/pharext.org] / app / Session.php
index 87189dc0bacda2584fe589573467cf19c4ce042d..af1b8e74e4c06afd9e56b72f315670579014a516 100644 (file)
@@ -3,14 +3,26 @@
 namespace app;
 
 use ArrayAccess;
-use merry\Config;
+use http\Env\Response;
+use http\Params;
 
 class Session implements ArrayAccess
 {
-       function __construct(Config $config) {
+       function __construct(Config $config, BaseUrl $baseUrl, Response $response) {
+               ini_set("session.cookie_path", $baseUrl->path);
                foreach ($config->session as $key => $val) {
                        ini_set("session.$key", $val);
                }
+               if (ini_get("session.use_cookies")) {
+                       $response->addHeader("Vary", "cookie");
+               }
+               $response->addHeader("Cache-Control",
+                       new Params([
+                               "private" => true,
+                               "must-revalidate" => true,
+                               "max-age" => ini_get("session.cache_expire") * 60
+                       ])
+               );
                session_start();
        }