session.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. 'use strict'
  2. /** @type {import('@adonisjs/framework/src/Env')} */
  3. const Env = use('Env')
  4. module.exports = {
  5. /*
  6. |--------------------------------------------------------------------------
  7. | Session Driver
  8. |--------------------------------------------------------------------------
  9. |
  10. | The session driver to be used for storing session values. It can be
  11. | cookie, file or redis.
  12. |
  13. | For `redis` driver, make sure to install and register `@adonisjs/redis`
  14. |
  15. */
  16. driver: Env.get('SESSION_DRIVER', 'cookie'),
  17. /*
  18. |--------------------------------------------------------------------------
  19. | Cookie Name
  20. |--------------------------------------------------------------------------
  21. |
  22. | The name of the cookie to be used for saving session id. Session ids
  23. | are signed and encrypted.
  24. |
  25. */
  26. cookieName: 'adonis-session',
  27. /*
  28. |--------------------------------------------------------------------------
  29. | Clear session when browser closes
  30. |--------------------------------------------------------------------------
  31. |
  32. | If this value is true, the session cookie will be temporary and will be
  33. | removed when browser closes.
  34. |
  35. */
  36. clearWithBrowser: true,
  37. /*
  38. |--------------------------------------------------------------------------
  39. | Session age
  40. |--------------------------------------------------------------------------
  41. |
  42. | This value is only used when `clearWithBrowser` is set to false. The
  43. | age must be a valid https://npmjs.org/package/ms string or should
  44. | be in milliseconds.
  45. |
  46. | Valid values are:
  47. | '2h', '10d', '5y', '2.5 hrs'
  48. |
  49. */
  50. age: '2h',
  51. /*
  52. |--------------------------------------------------------------------------
  53. | Cookie options
  54. |--------------------------------------------------------------------------
  55. |
  56. | Cookie options defines the options to be used for setting up session
  57. | cookie
  58. |
  59. */
  60. cookie: {
  61. httpOnly: true,
  62. sameSite: false,
  63. path: '/'
  64. },
  65. /*
  66. |--------------------------------------------------------------------------
  67. | Sessions location
  68. |--------------------------------------------------------------------------
  69. |
  70. | If driver is set to file, we need to define the relative location from
  71. | the temporary path or absolute url to any location.
  72. |
  73. */
  74. file: {
  75. location: 'sessions'
  76. },
  77. /*
  78. |--------------------------------------------------------------------------
  79. | Redis config
  80. |--------------------------------------------------------------------------
  81. |
  82. | The configuration for the redis driver. By default we reference it from
  83. | the redis file. But you are free to define an object here too.
  84. |
  85. */
  86. redis: {
  87. host: '127.0.0.1',
  88. port: 6379,
  89. password: null,
  90. db: 0,
  91. keyPrefix: ''
  92. }
  93. }