i have a module to parse serialized php sessions

Mauro Stettler mauro.stettler at gmail.com
Sun Feb 14 05:13:29 MSK 2010


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
 37                 memcached_pass;
 38             }
 44             php_session_parse $admin_right $session
 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:


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:



More information about the nginx mailing list