Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add writable/session directory and set default App::sessionSavePath to it #1194

Merged
merged 2 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ writable/logs/*
!writable/logs/index.html
!writable/logs/.htaccess

writable/session/*
!writable/session/index.html
!writable/session/.htaccess

writable/uploads/*
!writable/uploads/index.html
!writable/uploads/.htaccess
Expand Down
2 changes: 1 addition & 1 deletion application/Config/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class App extends BaseConfig
public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler';
public $sessionCookieName = 'ci_session';
public $sessionExpiration = 7200;
public $sessionSavePath = null;
public $sessionSavePath = WRITEPATH . 'session';
public $sessionMatchIP = false;
public $sessionTimeToUpdate = 300;
public $sessionRegenerateDestroy = false;
Expand Down
8 changes: 7 additions & 1 deletion system/Session/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ public function __construct($config)
}
else
{
$this->savePath = rtrim(ini_get('session.save_path'), '/\\');
$sessionPath = rtrim(ini_get('session.save_path'), '/\\');
if (! $sessionPath)
{
$sessionPath = WRITEPATH . 'session';
}

$this->savePath = $sessionPath;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for fallback when App:: sessionSavePath is null, but ini_get('session.save_path') returns empty string.

}
}

Expand Down
6 changes: 6 additions & 0 deletions writable/session/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
11 changes: 11 additions & 0 deletions writable/session/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>

<p>Directory access is forbidden.</p>

</body>
</html>