0
我试图使用光油设置一个cookie,但没有看到如何处理多个相同名称的标题。举例来说,如果多个Cookie需要设置,应用程序将发送:使用光油3来设置Cookie
Set-Cookie:sources=source+2; expires=Tue, 04-Nov-2014 17:12:50 GMT; path=/; domain=.xampp.com.local
Set-Cookie:someOtherCookie=othervalue; expires=Tue, 04-Nov-2014 17:12:50 GMT; path=/; domain=.xampp.com.local
清漆,我会永远只需要设置一个cookie的,但如果后端响应包括一个Set-Cookie头,或者客户端已经有Cookie,我想确定我没有在设置我的Cookie的过程中销毁它们。
从Nexcess松节油扩展似乎工作的一些神奇的C内部与负责建立会话如下:
sub generate_session {
# generate a UUID and add `frontend=$UUID` to the Cookie header, or use SID
# from SID URL param
if (req.url ~ ".*[&?]SID=([^&]+).*") {
set req.http.X-Varnish-Faked-Session = regsub(
req.url, ".*[&?]SID=([^&]+).*", "frontend=\1");
} else {
C{
char uuid_buf [50];
generate_uuid(uuid_buf);
VRT_SetHdr(sp, HDR_REQ,
"\030X-Varnish-Faked-Session:",
uuid_buf,
vrt_magic_string_end
);
}C
}
if (req.http.Cookie) {
# client sent us cookies, just not a frontend cookie. try not to blow
# away the extra cookies
std.collect(req.http.Cookie);
set req.http.Cookie = req.http.X-Varnish-Faked-Session +
"; " + req.http.Cookie;
} else {
set req.http.Cookie = req.http.X-Varnish-Faked-Session;
}
}
sub generate_session_expires {
# sets X-Varnish-Cookie-Expires to now + esi_private_ttl in format:
# Tue, 19-Feb-2013 00:14:27 GMT
# this isn't threadsafe but it shouldn't matter in this case
C{
time_t now = time(NULL);
struct tm now_tm = *gmtime(&now);
now_tm.tm_sec += 3600;
mktime(&now_tm);
char date_buf [50];
strftime(date_buf, sizeof(date_buf)-1, "%a, %d-%b-%Y %H:%M:%S %Z", &now_tm);
VRT_SetHdr(sp, HDR_RESP,
"\031X-Varnish-Cookie-Expires:",
date_buf,
vrt_magic_string_end
);
}C
}
他们正在检查,看看是否用户已经有一个前端的cookie有以下几点:
if (req.http.Cookie !~ "frontend=") {
# it's a real user, make up a new session for them
call generate_session;
}
那么,我该如何处理的情况下,其中一个或多个以下的正在发生:
- 光油是增加前端的Magento的(松节油)=饼干
- 后台返回一个或多个Cookie
- 的客户端已经有一个或多个Cookie