fastcgi_cache_key with cookie

António P. P. Almeida appa at perusio.net
Wed Dec 28 16:52:34 UTC 2011


On 28 Dez 2011 13h55 WET, nginx-forum at nginx.us wrote:

> António P. P. Almeida Wrote:
> -------------------------------------------------------
>> On 28 Dez 2011 04h15 WET, nginx-forum at nginx.us
>> wrote:
>>
>>
>>>> map $http_cookie $session_id {
>>>> default '';
>>>> ~SESS(?<session_guid>[[:alnum:]]+)
>>>> $session_guid;
>>>> }
>>>>
>>>> --- appa
>>>>
>>>
>>> That regex will only get you the cookie name
>> (md5 of domain) without
>>> the cookie value.  You will want the equal sign
>> in there so you get
>>> both name and value:
>>>
>>> ~^.*SESS(?<key>[\w\=]+).*$ $key;
>>>
>>> or just the value:
>>>
>>> ~^.*SESS.+\=(?<key>[\w]+).*$ $key;
>>
>> MD5 of the domain? How? AFAIK it's much more
>> elaborate than that.
>>
>> See:
>> http://svn.php.net/viewvc/php/php-src/branches/PHP
>> _5_3_8/ext/session/session.c?revision=315335&view=
>> markup
>>
>> --- appa
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>
> Drupal session cookie is in the form: session_name = session_id e.g.
> SESSc4f381f0375dba8f9670647c311307a9=b051bb99415e65d3d921f7891f3ca91f
>
> The session_name is either session_name('SESS'
> . md5($cookie_domain)) from your settings file or
> session_name('SESS' . md5(explode('://', $base_url, 2))) see
> http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/conf_init/6
>
> Your regex was only getting the session_name and not the session_id

If that's the case then why get the cookie name? Just get the value
which is the session ID.

map $http_cookie $session_id {
    default '';
    ~SESS[[:alnum:]]+=(?<session_guid>[[:alnum:]]+) $session_guid;
}

--- appa



More information about the nginx mailing list