It’s very frustrating. For requests to visit the homepage, the uid can be analyzed from the cookie, but other requests cannot.
Print the cookie directly, there is no difference between the homepage and other requests
My Nginx configuration file
set $uid "-"; if ( $http_cookie ~* "uid=(\S+)(;.*|$)"){ set $uid ; } log_format s_access '[$time_local] $remote_addr - "$request" - ' '$status - $body_bytes_sent - "$http_referer" - ' '"$http_user_agent" - $request_time - "$uid" "$http_cookie"';
Two Access Logs, the upper one is access/list cookie. In the last "", the previous "" is empty. It seems that if comes in, but the uid is empty; the next one is access/cookie. Like the previous one, within "", the previous "" has a value and is recognized.
Very depressing!
[04/Dec/2012:21:44:43 +0800] 145.122.142.124 - "GET /list HTTP/1.1" - 200 - 18573 - "-" - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.60 Safari/537.11" - 0.079 - "" "__c_uactiveat=1350108823468; __c_review=46; __c_last=1351061042906; __c_visitor=1350104003730701; uid=103; __utma=224849432.425128387.1339588739.1354606821.1354625898.809; __utmb=224849432.12.10.1354625898; __utmc=224849432; __utmz=224849432.1354108162.783.24.utmcsr=e.weibo.com|utmccn=(referral)|utmcmd=referral|utmcct=/2036070420/z7ixpvGv4; sess=50b8f.796" [04/Dec/2012:21:45:18 +0800] 145.122.142.124 - "GET / HTTP/1.1" - 200 - 13449 - "-" - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.60 Safari/537.11" - 0.248 - "1030000000091320" "__c_uactiveat=1350108823468; __c_review=46; __c_last=1351061042906; __c_visitor=1350104003730701; uid=103; __utma=224849432.425128387.1339588739.1354606821.1354625898.809; __utmb=224849432.13.10.1354625898; __utmc=224849432; __utmz=224849432.1354108162.783.24.utmcsr=e.weibo.com|utmccn=(referral)|utmcmd=referral|utmcct=/2036070420/z7ixpvGv4; sess=50b8f.796"
$cookie_xxx xxx is the cookie key
Cookie needs to be accessed once and then returned to the client.
There is no cookie when visiting the client for the first time