# How to get uid\_set by userid module in php

**URL:** <https://www.ruby-forum.com/t/how-to-get-uid-set-by-userid-module-in-php/184352>\
**Category:** NGINX\
**Created:** [March 1, 2010, 11:15am UTC](https://www.ruby-forum.com/t/how-to-get-uid-set-by-userid-module-in-php/184352 "2010-03-01T11:15:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lostsnow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3d9bf3/32.png) [@lostsnow](https://www.ruby-forum.com/u/lostsnow)\
**Post date:** [March 1, 2010, 11:15am UTC](https://www.ruby-forum.com/t/how-to-get-uid-set-by-userid-module-in-php/184352/1 "2010-03-01T11:15:57Z")

</div>

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:

> **[how to get uid\_set by userid module in php](https://forum.nginx.org/read.php?2,58522,58522#msg-58522)**
>
> i set \[code\] fastcgi\_param UID\_GOT $uid\_got; fastcgi\_param UID\_SET $uid\_set; \[/code\] 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 v

---

<div class="post-metadata">

**Author:** ![lostsnow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3d9bf3/32.png) [@lostsnow](https://www.ruby-forum.com/u/lostsnow)\
**Post date:** [March 1, 2010, 12:05pm UTC](https://www.ruby-forum.com/t/how-to-get-uid-set-by-userid-module-in-php/184352/2 "2010-03-01T12:05:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lostsnow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3d9bf3/32.png) [@lostsnow](https://www.ruby-forum.com/u/lostsnow)\
**Post date:** [March 2, 2010, 3:55am UTC](https://www.ruby-forum.com/t/how-to-get-uid-set-by-userid-module-in-php/184352/3 "2010-03-02T03:55:44Z")

</div>

By the way,

how can i decode the cookie from the client

for example:

wKiAg0uMcKcZqg3nAwMDAg==

decode to

8380A8C0A7708C4BE70DAA1902030303

Posted at Nginx Forum:

> **[Re: how to get uid\_set by userid module in php](https://forum.nginx.org/read.php?2,58522,58867#msg-58867)**
>
> i set \[code\] fastcgi\_param UID\_GOT $uid\_got; fastcgi\_param UID\_SET $uid\_set; \[/code\] 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 v

---

<div class="post-metadata">

**Author:** ![lostsnow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3d9bf3/32.png) [@lostsnow](https://www.ruby-forum.com/u/lostsnow)\
**Post date:** [November 19, 2011, 5:31am UTC](https://www.ruby-forum.com/t/how-to-get-uid-set-by-userid-module-in-php/184352/4 "2011-11-19T05:31:24Z")

</div>

$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](http://forum.nginx.org/read.php?2,215035)

Posted at Nginx Forum:

> **[Re: how to get uid\_set by userid module in php](https://forum.nginx.org/read.php?2,58522,218594#msg-218594)**
>
> i set \[code\] fastcgi\_param UID\_GOT $uid\_got; fastcgi\_param UID\_SET $uid\_set; \[/code\] 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 v
