Number of Cookies Supported in PHP


How Many Cookies Can You Set in PHP?



How many cookies can you set in your PHP page? The answer is depending what is the Web browser your visitor is using. Each browser has its own limit:

  • Internet Explorer (IE): 20
  • Mozilla Firefox: 50

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

  $count = count($_COOKIE);
  $name = "Cookie_".($count+1);
  $value = "";
  setcookie($name, $value);
  print("One cookies were added.\n"); 
  print("$count cookies received.\n");
  foreach ($_COOKIE as $name => $value) {
     print "  $name = $value\n";

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

One cookies were added.
0 cookies received.

Click the refresh button, you will see:

One cookies were added.
1 cookies received.
  Cookie_1 =

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


Single Cookie Size Limit in PHP

Firefox Storing Persistent Cookies in PHP

Understanding and Managing Cookies in PHP

⇑⇑ PHP Tutorials

2016-10-30, 1674🔥, 0💬