From 7c18649859762a5c1760c4f2310e8ffe6966d729 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Fri, 10 Nov 2023 00:45:22 +0000 Subject: [PATCH] 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. --- index.template.html | 3 ++- js/clean-cookies.php | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 js/clean-cookies.php diff --git a/index.template.html b/index.template.html index 3aac30a1e..cc3ba8c76 100644 --- a/index.template.html +++ b/index.template.html @@ -124,4 +124,5 @@ https://psim.us/dev - + + diff --git a/js/clean-cookies.php b/js/clean-cookies.php new file mode 100644 index 000000000..10aa87c22 --- /dev/null +++ b/js/clean-cookies.php @@ -0,0 +1,21 @@ + $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.")'; +}