Search code examples
phpmod-lua

Where is the Php source code for generating the unique session sequence?


I've not found any session handling with mod_lua. So I guess I'll have to write my own session handler. Note: that's great because Php lacks of handling timeouts by values, it only handles timeout for the whole session.

I'm just looking for the source code of Php where it generates the unique number of the session, to make it with mod_lua.

I've downloaded the whole Php code source but... I don't know where to look.


Solution

  • Why not just use r.log_id to get a unique number? or something like:

    local session_id = r:getcookie("lua_sessionid")
    if not session_id then 
        session_id = r:sha1(r.log_id .. r.clock())
        r:setcookie{
            key = "lua_sessionid",
            value = session_id
        }
    end
    

    Alternately, see http://modlua.org/recipes/cookies for how to work with cookies and unique IDs.