@@ -169,10 +169,11 @@ public function isHeaderOnly()
169169 * @param string $domain Domain name
170170 * @param bool $secure If secure
171171 * @param bool $httpOnly If uses only HTTP
172+ * @param bool $samesite If uses Same-site cookies
172173 *
173174 * @throws sfException If fails to set the cookie
174175 */
175- public function setCookie ($ name , $ value , $ expire = null , $ path = '/ ' , $ domain = '' , $ secure = false , $ httpOnly = false )
176+ public function setCookie ($ name , $ value , $ expire = null , $ path = '/ ' , $ domain = '' , $ secure = false , $ httpOnly = false , $ samesite = '' )
176177 {
177178 if (null !== $ expire ) {
178179 if (is_numeric ($ expire )) {
@@ -193,6 +194,7 @@ public function setCookie($name, $value, $expire = null, $path = '/', $domain =
193194 'domain ' => $ domain ,
194195 'secure ' => $ secure ? true : false ,
195196 'httpOnly ' => $ httpOnly ,
197+ 'samesite ' => $ samesite ,
196198 ];
197199 }
198200
@@ -359,7 +361,14 @@ public function sendHttpHeaders()
359361 foreach ($ this ->cookies as $ cookie ) {
360362 $ expire = isset ($ cookie ['expire ' ]) ? $ cookie ['expire ' ] : 0 ;
361363 $ domain = isset ($ cookie ['domain ' ]) ? $ cookie ['domain ' ] : '' ;
362- setrawcookie ($ cookie ['name ' ], $ cookie ['value ' ], $ expire , $ cookie ['path ' ], $ domain , $ cookie ['secure ' ], $ cookie ['httpOnly ' ]);
364+ setrawcookie ($ cookie ['name ' ], $ cookie ['value ' ], [
365+ 'expires ' => $ expire ,
366+ 'path ' => $ cookie ['path ' ],
367+ 'domain ' => $ domain ,
368+ 'secure ' => $ cookie ['secure ' ],
369+ 'httpOnly ' => $ cookie ['httpOnly ' ],
370+ 'samesite ' => $ cookie ['samesite ' ],
371+ ]);
363372
364373 if ($ this ->options ['logging ' ]) {
365374 $ this ->dispatcher ->notify (new sfEvent ($ this , 'application.log ' , [sprintf ('Send cookie "%s": "%s" ' , $ cookie ['name ' ], $ cookie ['value ' ])]));
0 commit comments