Fixed issue with cookies
This commit is contained in:
parent
5888e2cdfb
commit
38fa75402b
|
@ -1 +1 @@
|
||||||
APP_SUBDIR=/ # Subpath your app is running, LEAVE EMPTY IF RUNNING FROM /
|
APP_SUBDIR=/ # Subpath your app is running, defaults to /
|
||||||
|
|
|
@ -4,7 +4,7 @@ use Helpers\Settings;
|
||||||
|
|
||||||
class Misc {
|
class Misc {
|
||||||
static public function getSubDir(): string {
|
static public function getSubDir(): string {
|
||||||
return isset($_ENV['APP_SUBDIR']) && !empty($_ENV['APP_SUBDIR']) ? $_ENV['APP_SUBDIR'] : '';
|
return isset($_ENV['APP_SUBDIR']) && !empty($_ENV['APP_SUBDIR']) ? $_ENV['APP_SUBDIR'] : '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getView(string $template): string {
|
static public function getView(string $template): string {
|
||||||
|
@ -24,7 +24,11 @@ class Misc {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function latte(): \Latte\Engine {
|
static public function latte(): \Latte\Engine {
|
||||||
|
// Workaround to avoid weird path issues
|
||||||
$subdir = Misc::getSubDir();
|
$subdir = Misc::getSubDir();
|
||||||
|
if ($subdir === '/') {
|
||||||
|
$subdir = '';
|
||||||
|
}
|
||||||
$latte = new \Latte\Engine;
|
$latte = new \Latte\Engine;
|
||||||
$latte->setTempDirectory(__DIR__ . '/../cache/views');
|
$latte->setTempDirectory(__DIR__ . '/../cache/views');
|
||||||
$latte->addFunction('assets', function (string $name, string $type) use ($subdir) {
|
$latte->addFunction('assets', function (string $name, string $type) use ($subdir) {
|
||||||
|
|
|
@ -16,6 +16,6 @@ class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function set(string $name, string $value) {
|
static public function set(string $name, string $value) {
|
||||||
setcookie($name, $value, time()+60*60*24*30, '', '', true, true);
|
setcookie($name, $value, time()+60*60*24*30, Misc::getSubDir(), '', isset($_SERVER['HTTPS']), true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue