Skip to content

Commit 0996697

Browse files
author
epriestley
committed
Remove 4-way cookie purge logic
Summary: HPHP has behaviorial differences from PHP which make this logic problematic and we provide a good error message to users when there's a cookie issue now, so unsplit the cookie logic and just clear the same cookie we'd otherwise set, as per ssl / base domain. Test Plan: Logged in and out of my local install. Reviewers: jungejason Reviewed By: jungejason CC: aran, jungejason Differential Revision: 876
1 parent 701bf83 commit 0996697

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

src/aphront/request/AphrontRequest.php

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -204,33 +204,16 @@ final public function setCookie($name, $value, $expire = null) {
204204
$expire = time() + (60 * 60 * 24 * 365 * 5);
205205
}
206206

207-
if ($value == '') {
208-
// NOTE: If we're clearing the cookie, also clear it on the entire
209-
// domain and both HTTP/HTTPS versions. This allows us to clear older
210-
// cookies which we didn't scope as tightly. Eventually we could remove
211-
// this, although it doesn't really hurt us. Basically, we're just making
212-
// really sure that cookies get cleared when we try to clear them.
213-
$secure_options = array(true, false);
214-
$domain_options = array('', $base_domain);
215-
} else {
216-
// Otherwise, when setting cookies, set only one tightly-scoped cookie.
217-
$is_secure = ($base_protocol == 'https');
218-
$secure_options = array($is_secure);
219-
$domain_options = array($base_domain);
220-
}
221-
222-
foreach ($secure_options as $cookie_secure) {
223-
foreach ($domain_options as $cookie_domain) {
224-
setcookie(
225-
$name,
226-
$value,
227-
$expire,
228-
$path = '/',
229-
$cookie_domain,
230-
$cookie_secure,
231-
$http_only = true);
232-
}
233-
}
207+
$is_secure = ($base_protocol == 'https');
208+
209+
setcookie(
210+
$name,
211+
$value,
212+
$expire,
213+
$path = '/',
214+
$base_domain,
215+
$is_secure,
216+
$http_only = true);
234217
}
235218

236219
final public function setUser($user) {

0 commit comments

Comments
 (0)