aboutsummaryrefslogtreecommitdiffstats
path: root/server/resty/session/identifiers/random.lua
blob: a2f97392d80b5e5ae3ace4ceb9d5c97302a9f641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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