Question

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.

Was it helpful?

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.

OTHER TIPS

The code for generating PHP session ids is in php_session_create_id, which is available for anyone to view at https://github.com/php/php-src/blob/0021095c40a2c2d3d95398c48ae83a06f1381f71/ext/session/session.c#L284

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top