fastcgi_cache_key with cookie

brianmercer nginx-forum at nginx.us
Wed Dec 28 13:55:44 UTC 2011


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

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,220510,220596#msg-220596



More information about the nginx mailing list