@@ -75,23 +75,43 @@ session cookie, if there is one, and get rid of all other cookies so that pages
75
75
are cached if there is no active session. Unless you changed the default
76
76
configuration of PHP, your session cookie has the name ``PHPSESSID ``:
77
77
78
- .. code -block :: varnish4
78
+ .. configuration -block ::
79
79
80
- sub vcl_recv {
81
- // Remove all cookies except the session ID.
82
- if (req.http.Cookie) {
83
- set req.http.Cookie = ";" + req.http.Cookie;
84
- set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
85
- set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
86
- set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
87
- set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
88
-
89
- if (req.http.Cookie == "") {
90
- // If there are no more cookies, remove the header to get page cached.
91
- remove req.http.Cookie;
80
+ .. code-block :: varnish4
81
+
82
+ sub vcl_recv {
83
+ // Remove all cookies except the session ID.
84
+ if (req.http.Cookie) {
85
+ set req.http.Cookie = ";" + req.http.Cookie;
86
+ set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
87
+ set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
88
+ set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
89
+ set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
90
+
91
+ if (req.http.Cookie == "") {
92
+ // If there are no more cookies, remove the header to get page cached.
93
+ unset req.http.Cookie;
94
+ }
95
+ }
96
+ }
97
+
98
+ .. code-block :: varnish3
99
+
100
+ sub vcl_recv {
101
+ // Remove all cookies except the session ID.
102
+ if (req.http.Cookie) {
103
+ set req.http.Cookie = ";" + req.http.Cookie;
104
+ set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
105
+ set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
106
+ set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
107
+ set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
108
+
109
+ if (req.http.Cookie == "") {
110
+ // If there are no more cookies, remove the header to get page cached.
111
+ remove req.http.Cookie;
112
+ }
92
113
}
93
114
}
94
- }
95
115
96
116
.. tip ::
97
117
0 commit comments