NativeFileSessionHandler.php 1.0 KB

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