Single Cookie Size Limit in PHP


How Large Can a Single Cookie Be in PHP?



How large can a single cookie be? The answer is depending what is the Web browser your visitor is using. Each browser has its own limit:

  • Internet Explorer (IE): about 3904 bytes
  • Mozilla Firefox: about 3136 bytes

If you want to test this limit, copy this sample script, huge_cookies.php, to your Web server:

  if (isset($_COOKIE["HomeSite"])) {
    $value = $_COOKIE["HomeSite"];
  } else {
    $value = "";
  $value .= "";
  setcookie("HomeSite", $value);
  print("Large cookie set with ".strlen($value)." characters.\n"); 

Open your browser to this page for first time, you will see:

Large cookie set with 32 characters.

Click the refresh button, you will see:

Large cookie set with 64 characters.

Keep clicking the refresh button, you will see the limit of your browser.


Cookies Encoded during Transportation in PHP

Number of Cookies Supported in PHP

Understanding and Managing Cookies in PHP

⇑⇑ PHP Tutorials

2016-10-30, 1978🔥, 0💬