2016-10-11 12 views
0

VCL에서 쿠키를 설정할 때 만료 날짜를 지정하고 싶습니다. 나는 현재 이런 일이 :쿠키를 설정할 때 만료 날짜 지정

add resp.http.Set-Cookie = "language=" + req.http.X-Language + "; path=/"; 

나는 이런 식으로 뭔가를 추가해야합니다 알고 :

Expires=Thu, 01 Jan 1970 00:00:00 GMT 

나 동적으로 설정 할 수 니스에 내장 된 기능이 있는가 만료일은 앞으로 무엇인가? 나는 그들의 문서를 보았다. 그러나 지금까지는 운이 없다.

대단히 감사합니다.

- 천사

답변

2

UPDATE - 작업 솔루션 : 다음 문서에서 이 구문은 Fastly에 고유하지만 난 그것을 사용하여 작업 가지고

확실하지 경우 : time.add(now,1d)을 :

add resp.http.Set-Cookie = "language=" + req.http.X-Language + ";expires="+ time.add(now,1d) +"; path=/"; 
+0

그것은 나타납니다 빠르게 구문의 조금만이 될 수 있습니다. – Danack

0

당신이 니스 4를 사용하는 경우, 당신은 쿠키 VMOD를 사용해야합니다. https://github.com/varnish/varnish-modules/blob/master/docs/vmod_cookie.rst

 
format_rfc1123 

STRING format_rfc1123(TIME now, DURATION timedelta) 
Description 
Get a RFC1123 formatted date string suitable for inclusion in a Set-Cookie response header. 

Care should be taken if the response has multiple Set-Cookie headers. In that case the header vmod should be used. 

Example 
sub vcl_deliver { 
     # Set a userid cookie on the client that lives for 5 minutes. 
     set resp.http.Set-Cookie = "userid=" + req.http.userid + "; Expires=" + cookie.format_rfc1123(now, 5m) + "; httpOnly"; 
}