Skip to content

Commit

Permalink
fix #1473 #1468 セッション設定を見直した
Browse files Browse the repository at this point in the history
- ガベージコレクションでの削除が完全でないためセッションファイルが肥大化するので、gc_divisor を 1 にして確実に削除
- cookieTimeout は、timeout の設定を引き継ぐ仕様のため設定を削除
- セッションの有効期限を `/app/Config/session.php` で簡単に変更できるように調整
  • Loading branch information
ryuring committed May 15, 2020
1 parent 2cc5a59 commit a9d2766
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
23 changes: 22 additions & 1 deletion app/Config/session.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
<?php
require BASER_CONFIGS .'session.php';
/**
* baserCMS : Based Website Development Project <http://basercms.net>
* Copyright (c) baserCMS Users Community <http://basercms.net/community/>
*
* @copyright Copyright (c) baserCMS Users Community
* @link http://basercms.net baserCMS Project
* @package Baser.Config
* @since baserCMS v 0.1.0
* @license http://basercms.net/license/index.html
*/

/**
* セッション設定
*/

require BASER_CONFIGS .'session.php';

/**
* セッションの有効期限(分)
* デフォルト:2日間
*/
//Configure::write('Session.timeout', 60 * 24 * 2);
21 changes: 3 additions & 18 deletions lib/Baser/Config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,9 @@
*
* `/app/Config/setting.php` より先に読み込まれるため
* `Configure` の値を変更するには、`/app/Config/session.php` で設定する
*
* 【ブラウザを開いた状態においてセッションが切れる条件】
* session.gc_maxlifetime で設定された秒数ごとに一定の確率ごとにセッションが切れる
* 確率は、session.gc_probability で設定する。確実にタイムアウトさせたい場合は、100を設定する。
*/

if (empty($_SESSION)) {

/**
* セッションタイムアウト
*/
$timeout = 60 * 24;

/**
* ブラウザを閉じた後のセッションの有効期限
*/
$cookieTimeout = $timeout;

/**
* モバイル設定
Expand Down Expand Up @@ -75,16 +61,15 @@


Configure::write('Session', array_merge(Configure::read('Session'), [
'defaults' => 'cake',
'cookie' => 'BASERCMS',
'timeout' => $timeout,
'cookieTimeout' => $cookieTimeout,
'timeout' => 60 * 24 * 2,
'ini' => [
'session.serialize_handler' => 'php',
'session.save_path' => TMP . 'sessions',
'session.use_cookies' => $useCookies,
'session.use_trans_sid' => $useTransSid,
'session.gc_maxlifetime' => $timeout * 60,
'session.gc_divisor' => 100,
'session.gc_divisor' => 1,
'session.gc_probability' => 1,
'session.cookie_secure' => $cookieSecure
]
Expand Down

0 comments on commit a9d2766

Please sign in to comment.