Session.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Config\BaseConfig;
  4. use CodeIgniter\Session\Handlers\BaseHandler;
  5. use CodeIgniter\Session\Handlers\FileHandler;
  6. class Session extends BaseConfig
  7. {
  8. /**
  9. * --------------------------------------------------------------------------
  10. * Session Driver
  11. * --------------------------------------------------------------------------
  12. *
  13. * The session storage driver to use:
  14. * - `CodeIgniter\Session\Handlers\ArrayHandler` (for testing)
  15. * - `CodeIgniter\Session\Handlers\FileHandler`
  16. * - `CodeIgniter\Session\Handlers\DatabaseHandler`
  17. * - `CodeIgniter\Session\Handlers\MemcachedHandler`
  18. * - `CodeIgniter\Session\Handlers\RedisHandler`
  19. *
  20. * @var class-string<BaseHandler>
  21. */
  22. public string $driver = FileHandler::class;
  23. /**
  24. * --------------------------------------------------------------------------
  25. * Session Cookie Name
  26. * --------------------------------------------------------------------------
  27. *
  28. * The session cookie name, must contain only [0-9a-z_-] characters
  29. */
  30. public string $cookieName = 'ci_session';
  31. /**
  32. * --------------------------------------------------------------------------
  33. * Session Expiration
  34. * --------------------------------------------------------------------------
  35. *
  36. * The number of SECONDS you want the session to last.
  37. * Setting to 0 (zero) means expire when the browser is closed.
  38. */
  39. public int $expiration = 7200;
  40. /**
  41. * --------------------------------------------------------------------------
  42. * Session Save Path
  43. * --------------------------------------------------------------------------
  44. *
  45. * The location to save sessions to and is driver dependent.
  46. *
  47. * For the 'files' driver, it's a path to a writable directory.
  48. * WARNING: Only absolute paths are supported!
  49. *
  50. * For the 'database' driver, it's a table name.
  51. * Please read up the manual for the format with other session drivers.
  52. *
  53. * IMPORTANT: You are REQUIRED to set a valid save path!
  54. */
  55. public string $savePath = WRITEPATH . 'session';
  56. /**
  57. * --------------------------------------------------------------------------
  58. * Session Match IP
  59. * --------------------------------------------------------------------------
  60. *
  61. * Whether to match the user's IP address when reading the session data.
  62. *
  63. * WARNING: If you're using the database driver, don't forget to update
  64. * your session table's PRIMARY KEY when changing this setting.
  65. */
  66. public bool $matchIP = false;
  67. /**
  68. * --------------------------------------------------------------------------
  69. * Session Time to Update
  70. * --------------------------------------------------------------------------
  71. *
  72. * How many seconds between CI regenerating the session ID.
  73. */
  74. public int $timeToUpdate = 300;
  75. /**
  76. * --------------------------------------------------------------------------
  77. * Session Regenerate Destroy
  78. * --------------------------------------------------------------------------
  79. *
  80. * Whether to destroy session data associated with the old session ID
  81. * when auto-regenerating the session ID. When set to FALSE, the data
  82. * will be later deleted by the garbage collector.
  83. */
  84. public bool $regenerateDestroy = false;
  85. /**
  86. * --------------------------------------------------------------------------
  87. * Session Database Group
  88. * --------------------------------------------------------------------------
  89. *
  90. * DB Group for the database session.
  91. */
  92. public ?string $DBGroup = null;
  93. /**
  94. * --------------------------------------------------------------------------
  95. * Lock Retry Interval (microseconds)
  96. * --------------------------------------------------------------------------
  97. *
  98. * This is used for RedisHandler.
  99. *
  100. * Time (microseconds) to wait if lock cannot be acquired.
  101. * The default is 100,000 microseconds (= 0.1 seconds).
  102. */
  103. public int $lockRetryInterval = 100_000;
  104. /**
  105. * --------------------------------------------------------------------------
  106. * Lock Max Retries
  107. * --------------------------------------------------------------------------
  108. *
  109. * This is used for RedisHandler.
  110. *
  111. * Maximum number of lock acquisition attempts.
  112. * The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
  113. * seconds.
  114. */
  115. public int $lockMaxRetries = 300;
  116. }