Workaround for large cookies

The FCCDCF cookie frequently goes oversize, and has recently
been causing people to be unable to access PS because their total
cookie size is going over 8KB, above Apache's default maximum.

https://business.safety.google/adscookies/

It looks like this cookie is set by Google and, according to the
internet, sometimes gets filled with junk? I don't know of an
easy way to fix this, but I'm hoping this does it.
This commit is contained in:
Guangcong Luo 2023-11-10 00:45:22 +00:00
parent ed36b96882
commit 7c18649859
2 changed files with 23 additions and 1 deletions

View File

@ -124,4 +124,5 @@ https://psim.us/dev
<script src="//play.pokemonshowdown.com/js/battle-dex-search.js?"></script>
<script src="//play.pokemonshowdown.com/js/search.js?"></script>
<script src="//play.pokemonshowdown.com/data/aliases.js?" async="async"></script>
<script src="//play.pokemonshowdown.com/data/aliases.js?" async></script>
<script src="//play.pokemonshowdown.com/js/clean-cookies.php" async></script>

21
js/clean-cookies.php Normal file
View File

@ -0,0 +1,21 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$cleaned = false;
foreach ($_COOKIE as $name => $value) {
if (strlen($value) > 3000) {
setcookie($name, '', time()-1000, '/', 'play.pokemonshowdown.com');
setcookie($name, '', time()-1000, '/', '.play.pokemonshowdown.com');
setcookie($name, '', time()-1000, '/', 'pokemonshowdown.com');
setcookie($name, '', time()-1000, '/', '.pokemonshowdown.com');
$cleaned = true;
}
}
if ($cleaned) {
echo 'alert("You had a cookie which was too big to handle and had to be deleted. If you had cookie settings, they may not be right.")';
}