How to get uid_set by userid module in php

i set

fastcgi_param UID_GOT $uid_got;
fastcgi_param UID_SET $uid_set;

in my nginx configuration file

and enable userid module
but i can not get uid_set by $_SERVER[‘uid_set’] in php when a user
visit my site first time
and the uid_set is empty also in access log.

when i delete

fastcgi_param UID_GOT $uid_got;
fastcgi_param UID_SET $uid_set;

i can see uid_set value in access log.

the debug info is:

2010/03/01 17:17:25 15274#0: *3 http process request line
2010/03/01 17:17:25 15274#0: *3 recv: fd:10 437 of 32768
2010/03/01 17:17:25 15274#0: *3 http request line: “GET
/x.php?callback=xx HTTP/1.1”
2010/03/01 17:17:25 15274#0: *3 http uri: “/x.php”
2010/03/01 17:17:25 15274#0: *3 http args: “callback=xx”
2010/03/01 17:17:25 15274#0: *3 http exten: “php”
2010/03/01 17:17:25 15274#0: *3 http process request header line
2010/03/01 17:17:25 15274#0: *3 http header: “Host: 192.168.128.131”
2010/03/01 17:17:25 15274#0: 3 http header: “User-Agent: Mozilla/5.0
(Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2) Gecko/20100115 Firefox/3.6
(.NET CLR 3.5.30729) FirePHP/0.4”
2010/03/01 17:17:25 15274#0: 3 http header: "Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,
/
;q=0.8"
2010/03/01 17:17:25 15274#0: *3 http header: “Accept-Language:
zh-cn,zh;q=0.5”
2010/03/01 17:17:25 15274#0: *3 http header: “Accept-Encoding:
gzip,deflate”
2010/03/01 17:17:25 15274#0: 3 http header: "Accept-Charset:
GB2312,utf-8;q=0.7,
;q=0.7"
2010/03/01 17:17:25 15274#0: *3 http header: “Keep-Alive: 115”
2010/03/01 17:17:25 15274#0: *3 http header: “Connection: keep-alive”
2010/03/01 17:17:25 15274#0: *3 http header: “Cache-Control: max-age=0”
2010/03/01 17:17:25 15274#0: *3 http header done
2010/03/01 17:17:25 15274#0: *3 event timer del: 10: 1267435105986
2010/03/01 17:17:25 15274#0: *3 generic phase: 0
2010/03/01 17:17:25 15274#0: *3 test location: “/status”
2010/03/01 17:17:25 15274#0: 3 test location: ~ "..(php|php5)?$"
2010/03/01 17:17:25 15274#0: 3 using configuration "..(php|php5)?$"
2010/03/01 17:17:25 15274#0: *3 http cl:-1 max:8388608
2010/03/01 17:17:25 15274#0: *3 generic phase: 2
2010/03/01 17:17:25 15274#0: *3 post rewrite phase: 3
2010/03/01 17:17:25 15274#0: *3 generic phase: 4
2010/03/01 17:17:25 15274#0: *3 generic phase: 5
2010/03/01 17:17:25 15274#0: *3 access phase: 6
2010/03/01 17:17:25 15274#0: *3 access phase: 7
2010/03/01 17:17:25 15274#0: *3 post access phase: 8
2010/03/01 17:17:25 15274#0: *3 malloc: 00000000059241D0:4096
2010/03/01 17:17:25 15274#0: *3 http init upstream, client timer: 0
2010/03/01 17:17:25 15274#0: *3 epoll add event: fd:10 op:3 ev:80000005
2010/03/01 17:17:25 15274#0: *3 http script copy:
“GATEWAY_INTERFACECGI/1.1”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “GATEWAY_INTERFACE:
CGI/1.1”
2010/03/01 17:17:25 15274#0: *3 http script copy: “SERVER_SOFTWARE”
2010/03/01 17:17:25 15274#0: *3 http script copy: “nginx/”
2010/03/01 17:17:25 15274#0: *3 http script var: “0.7.64”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “SERVER_SOFTWARE:
nginx/0.7.64”
2010/03/01 17:17:25 15274#0: *3 http script copy: “QUERY_STRING”
2010/03/01 17:17:25 15274#0: *3 http script var: “callback=xx”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “QUERY_STRING:
callback=xx”
2010/03/01 17:17:25 15274#0: *3 http script copy: “REQUEST_METHOD”
2010/03/01 17:17:25 15274#0: *3 http script var: “GET”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “REQUEST_METHOD: GET”
2010/03/01 17:17:25 15274#0: *3 http script copy: “CONTENT_TYPE”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: "CONTENT_TYPE: "
2010/03/01 17:17:25 15274#0: *3 http script copy: “CONTENT_LENGTH”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: "CONTENT_LENGTH: "
2010/03/01 17:17:25 15274#0: *3 http script copy: “SCRIPT_FILENAME”
2010/03/01 17:17:25 15274#0: *3 http script var: “/var/www”
2010/03/01 17:17:25 15274#0: *3 http script var: “/x.php”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “SCRIPT_FILENAME:
/var/www/x.php”
2010/03/01 17:17:25 15274#0: *3 http script copy: “SCRIPT_NAME”
2010/03/01 17:17:25 15274#0: *3 http script var: “/x.php”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “SCRIPT_NAME: /x.php”
2010/03/01 17:17:25 15274#0: *3 http script copy: “REQUEST_URI”
2010/03/01 17:17:25 15274#0: *3 http script var: “/x.php?callback=xx”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “REQUEST_URI:
/x.php?callback=xx”
2010/03/01 17:17:25 15274#0: *3 http script copy: “DOCUMENT_URI”
2010/03/01 17:17:25 15274#0: *3 http script var: “/x.php”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “DOCUMENT_URI: /x.php”
2010/03/01 17:17:25 15274#0: *3 http script copy: “DOCUMENT_ROOT”
2010/03/01 17:17:25 15274#0: *3 http script var: “/var/www”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “DOCUMENT_ROOT:
/var/www”
2010/03/01 17:17:25 15274#0: *3 http script copy: “SERVER_PROTOCOL”
2010/03/01 17:17:25 15274#0: *3 http script var: “HTTP/1.1”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “SERVER_PROTOCOL:
HTTP/1.1”
2010/03/01 17:17:25 15274#0: *3 http script copy: “REMOTE_ADDR”
2010/03/01 17:17:25 15274#0: *3 http script var: “192.168.128.1”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “REMOTE_ADDR:
192.168.128.1”
2010/03/01 17:17:25 15274#0: *3 http script copy: “REMOTE_PORT”
2010/03/01 17:17:25 15274#0: *3 http script var: “4828”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “REMOTE_PORT: 4828”
2010/03/01 17:17:25 15274#0: *3 http script copy: “SERVER_ADDR”
2010/03/01 17:17:25 15274#0: *3 http script var: “192.168.128.131”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “SERVER_ADDR:
192.168.128.131”
2010/03/01 17:17:25 15274#0: *3 http script copy: “SERVER_PORT”
2010/03/01 17:17:25 15274#0: *3 http script var: “80”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “SERVER_PORT: 80”
2010/03/01 17:17:25 15274#0: *3 http script copy: “SERVER_NAME”
2010/03/01 17:17:25 15274#0: *3 http script var: “192.168.128.131”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “SERVER_NAME:
192.168.128.131”
2010/03/01 17:17:25 15274#0: *3 http script copy: “UID_GOT”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “UID_GOT: "
2010/03/01 17:17:25 15274#0: *3 http script copy: “UID_SET”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “UID_SET: "
2010/03/01 17:17:25 15274#0: *3 http script copy: “REDIRECT_STATUS200”
2010/03/01 17:17:25 15274#0: *3 fastcgi param: “REDIRECT_STATUS: 200”
2010/03/01 17:17:25 15274#0: *3 http cleanup add: 000000000592D0B8
2010/03/01 17:17:25 15274#0: *3 get rr peer, try: 1
2010/03/01 17:17:25 15274#0: *3 socket 11
2010/03/01 17:17:25 15274#0: *3 epoll add connection: fd:11 ev:80000005
2010/03/01 17:17:25 15274#0: *3 connect to unix:/tmp/php-cgi.sock,
fd:11 #4
2010/03/01 17:17:25 15274#0: *3 connected
2010/03/01 17:17:25 15274#0: *3 http upstream connect: 0
2010/03/01 17:17:25 15274#0: *3 http upstream send request
2010/03/01 17:17:25 15274#0: *3 chain writer buf fl:0 s:904
2010/03/01 17:17:25 15274#0: *3 chain writer in: 00000000059246F8
2010/03/01 17:17:25 15274#0: *3 writev: 904
2010/03/01 17:17:25 15274#0: *3 chain writer out: 0000000000000000
2010/03/01 17:17:25 15274#0: *3 event timer add: 11:
300000:1267435345986
2010/03/01 17:17:25 15274#0: timer delta: 0
2010/03/01 17:17:25 15274#0: posted events 0000000000000000
2010/03/01 17:17:25 15274#0: worker cycle
2010/03/01 17:17:25 15274#0: epoll timer: 300000
2010/03/01 17:17:25 15274#0: epoll: fd:11 ev:0004 d:00002B240AB722F1
2010/03/01 17:17:25 15274#0: *3 http upstream request:
“/x.php?callback=xx”
2010/03/01 17:17:25 15274#0: *3 http upstream dummy handler
2010/03/01 17:17:25 15274#0: epoll: fd:10 ev:0004 d:00002B240AB72239
2010/03/01 17:17:25 15274#0: *3 http run request: “/x.php?callback=xx”
2010/03/01 17:17:25 15274#0: *3 http upstream check client, write
event:1, “/x.php”
2010/03/01 17:17:25 15274#0: *3 http upstream recv(): -1 (11: Resource
temporarily unavailable)
2010/03/01 17:17:25 15274#0: timer delta: 1
2010/03/01 17:17:25 15274#0: posted events 0000000000000000
2010/03/01 17:17:25 15274#0: worker cycle
2010/03/01 17:17:25 15274#0: epoll timer: 299999
2010/03/01 17:17:26 15274#0: epoll: fd:11 ev:0005 d:00002B240AB722F1
2010/03/01 17:17:26 15274#0: *3 http upstream request:
“/x.php?callback=xx”
2010/03/01 17:17:26 15274#0: *3 http upstream process header
2010/03/01 17:17:26 15274#0: *3 malloc: 0000000005953DE0:65536
2010/03/01 17:17:26 15274#0: *3 recv: fd:11 64 of 65536
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 01
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 06
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 00
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 01
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 00
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 35
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 03
2010/03/01 17:17:26 15274#0: *3 http fastcgi record byte: 00
2010/03/01 17:17:26 15274#0: *3 http fastcgi record length: 53
2010/03/01 17:17:26 15274#0: *3 http fastcgi parser: 0
2010/03/01 17:17:26 15274#0: *3 http fastcgi header: “X-Powered-By:
PHP/5.2.11”
2010/03/01 17:17:26 15274#0: *3 http fastcgi parser: 0
2010/03/01 17:17:26 15274#0: *3 http fastcgi header: “Content-type:
text/html”
2010/03/01 17:17:26 15274#0: *3 http fastcgi parser: 1
2010/03/01 17:17:26 15274#0: *3 http fastcgi header done
2010/03/01 17:17:26 15274#0: *3 uid cookie:
“uid=wKiAg0uLhiZT+zuqAwMDAg==; expires=Tue, 01-Mar-11 09:17:26 GMT;
domain=192.168.128.131; path=/”
2010/03/01 17:17:26 15274#0: *3 charset: “” > “utf-8”
2010/03/01 17:17:26 15274#0: *3 HTTP/1.1 200 OK
Server: nginx/0.7.64
Date: Mon, 01 Mar 2010 09:17:26 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.2.11
Set-Cookie: uid=wKiAg0uLhiZT+zuqAwMDAg==; expires=Tue, 01-Mar-11
09:17:26 GMT; domain=192.168.128.131; path=/
P3P: policyref=”/w3c/p3p.xml”, CP=“CURa ADMa DEVa PSAo PSDo OUR BUS UNI
PUR INT DEM STA PRE COM NAV OTC NOI DSP COR”
Content-Encoding: gzip

Posted at Nginx Forum:

Hello!

On Mon, Mar 01, 2010 at 05:15:19AM -0500, lostsnow wrote:

and the uid_set is empty also in access log.

when i delete

fastcgi_param UID_GOT $uid_got;
fastcgi_param UID_SET $uid_set;

i can see uid_set value in access log.

Variables $uid_got and $uid_set are only available after userid
filter during sending headers. This happens before ssi/xslt
filtering (and of course logging), just after headers filter
(which handles expires and add_header).

An attempt to use these variables before they are available will
cache an empty value and you’ll won’t be able to see real values
at all.

Maxim D.

By the way,

how can i decode the cookie from the client

for example:

wKiAg0uMcKcZqg3nAwMDAg==

decode to

8380A8C0A7708C4BE70DAA1902030303

Posted at Nginx Forum:

$bin = base64_decode(‘wKiAg0uMcKcZqg3nAwMDAg==’);
$uid = join(array_map(function($i){return strtoupper(dechex($i));},
unpack(“L*”, $bin)), “”);
print $uid;

see also nginx uid decoding using Base64.decode64

Posted at Nginx Forum: