session.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * This file is part of webman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<walkor@workerman.net>
  10. * @copyright walkor<walkor@workerman.net>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. use Webman\Session\FileSessionHandler;
  15. use Webman\Session\RedisSessionHandler;
  16. use Webman\Session\RedisClusterSessionHandler;
  17. return [
  18. 'type' => 'file', // or redis or redis_cluster
  19. 'handler' => FileSessionHandler::class,
  20. 'config' => [
  21. 'file' => [
  22. 'save_path' => runtime_path() . '/sessions',
  23. ],
  24. 'redis' => [
  25. 'host' => '127.0.0.1',
  26. 'port' => 6379,
  27. 'auth' => '',
  28. 'timeout' => 2,
  29. 'database' => '',
  30. 'prefix' => 'redis_session_',
  31. ],
  32. 'redis_cluster' => [
  33. 'host' => ['127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7001'],
  34. 'timeout' => 2,
  35. 'auth' => '',
  36. 'prefix' => 'redis_session_',
  37. ]
  38. ],
  39. 'session_name' => 'PHPSID',
  40. 'auto_update_timestamp' => false,
  41. 'lifetime' => 7*24*60*60,
  42. 'cookie_lifetime' => 365*24*60*60,
  43. 'cookie_path' => '/',
  44. 'domain' => '',
  45. 'http_only' => true,
  46. 'secure' => false,
  47. 'same_site' => '',
  48. 'gc_probability' => [1, 1000],
  49. ];