0

I'm unable to log into localhost and wondering if this is due to having 40-50 cookies on my machine.

Could this be the reason?

The site is set up to create a cookie for each article that's being viewed.

random
  • 9,774
  • 10
  • 66
  • 83
Cookie
  • 401
  • 1
  • 4
  • 4

2 Answers2

1

Don't create this many cookies.

Either

  • Serialize the IDs of all viewed articles into one cookie

  • Have one long-term cookie with a random ID, and store the associated data (article views, etc.) on server side. You'd have to do some garbage collection for this though, like clear out keys that haven't been used for more than six months or whatever.

that said, as @Michael points out, this is not necessarily the root cause of your problem. You'd have to give some more details to get specific answers.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • but how long can a cookie value be? – Cookie Jun 26 '11 at 23:27
  • @Cookie see [What are the current cookie limits in modern browsers?](http://stackoverflow.com/q/5381526) – Pekka Jun 26 '11 at 23:28
  • hmm I tried stuffing my data inside a single cookie, but the browser creates a new cookie every time I call setcookie(), even if the cookie has the same name :( – Cookie Jun 26 '11 at 23:40
1

The number of cookies is irrelevant. If there are lots and lots, it will increase the HTTP request size and slow things down a bit or even (as pointed out in comments below) exceed the maximum HTTP request size allowed, but if you are having problems it is more likely that you have some conflict like two cookies with the same name overwriting one another.

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
  • You can actually exceed the max request size on some web servers with too many cookies. – datasage Jun 26 '11 at 23:28
  • @datasage Yes absolutely, but that's a function of the amount of data passed, not the number of cookies. Of course the number of cookies is a major contributor. – Michael Berkowski Jun 26 '11 at 23:30