0

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.

Olivier Pons
  • 15,363
  • 26
  • 117
  • 213

2 Answers2

1

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.

Daniel Gruno
  • 111
  • 1
  • Thank you very much this was the answer i was looking for. – Olivier Pons May 07 '14 at 17:16
  • Ok I found the problem. I have to use `Logging Functions` so that there will be something like an id or whatever that is created. As long as I dont log something, `log_id` is `nil`... and as long as nothing is written, `log_id` is `nil` (I thought I could fake something like `r.trace8('test')` but it's not written so `log_id` stays `nil`)... – Olivier Pons May 07 '14 at 20:05
0

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

Joseph Scott
  • 121
  • 1
  • 3