Skip to content

Commit fbee4cf

Browse files
author
Drak
committed
Restore NativeFileSessionHandler
Partial revert "[HttpFoundation] Removed Native*Handler session save handler classes" This partially reverts commit b2cc580.
1 parent 8c2f35f commit fbee4cf

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
13+
14+
/**
15+
* NativeFileSessionHandler.
16+
*
17+
* Native session handler using PHP's built in file storage.
18+
*
19+
* @author Drak <drak@zikula.org>
20+
*/
21+
class NativeFileSessionHandler extends NativeSessionHandler
22+
{
23+
/**
24+
* Constructor.
25+
*
26+
* @param string $savePath Path of directory to save session files. Default null will leave setting as defined by PHP.
27+
*/
28+
public function __construct($savePath = null)
29+
{
30+
if (null === $savePath) {
31+
$savePath = ini_get('session.save_path');
32+
}
33+
34+
if ($savePath && !is_dir($savePath)) {
35+
mkdir($savePath, 0777, true);
36+
}
37+
38+
ini_set('session.save_handler', 'files');
39+
ini_set('session.save_path', $savePath);
40+
}
41+
}

0 commit comments

Comments
 (0)