aboutsummaryrefslogtreecommitdiffstats
path: root/server/resty/session/identifiers
diff options
context:
space:
mode:
Diffstat (limited to 'server/resty/session/identifiers')
-rw-r--r--server/resty/session/identifiers/random.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/server/resty/session/identifiers/random.lua b/server/resty/session/identifiers/random.lua
new file mode 100644
index 0000000..a2f9739
--- /dev/null
+++ b/server/resty/session/identifiers/random.lua
@@ -0,0 +1,13 @@
+local tonumber = tonumber
+local random = require "resty.random".bytes
+local var = ngx.var
+
+local defaults = {
+ length = tonumber(var.session_random_length, 10) or 16
+}
+
+return function(session)
+ local config = session.random or defaults
+ local length = tonumber(config.length, 10) or defaults.length
+ return random(length, true) or random(length)
+end