I have a module to parse serialized php sessions

hi

i recently wrote an nginx module that can extract certain values out
of a serialized php session. in my case i’m retrieving the php session
from a memcache. this thing isn’t tested in prod, in fact i started it
yesterday. but it seems to work and i can’t find any bigger problems
with it at the moment.

currently it works like this:

33 location / {
34 eval $session {
35 set $memcached_key
“d41d8cd98f00b204e9800998ecf8427e:5b9hm9rspbgajg22eqpqs6ang1”;
37 memcached_pass 192.168.1.237:11210;
38 }

44 php_session_parse $admin_right $session
“symfony/user/sfUser/attributes|s:10:"subscriber";s:7:"isAdmin"”;

53 if ($admin_right = “b:1”)
54 {
55 # do something
56 }

i think the format how i am specifying the value that i want to
extract from the session might be a little confusing (and there are no
docs yet). in the example the value that i want to extract is
specified with the string:

"symfony/user/sfUser/attributes|s:10:"subscriber";s:7:"isAdmin"

which means on the toplevel array i want the element
“symfony/user/sfUser/attributes”, second level i want the element
“s:10:"subscriber"”, third level i want the element
“s:7:"isAdmin"”. separators between the elements are ; and |. this
might seem confusing, but thats the way how its done in the php
session serialization…

i would be happy about some feedbacks. could a thing like this be
useful? i’m sure there are still bugs too…

thats the link:

mauro