开发者

Maximum 20 cookie per domain - Why?

I've just come across an interesting fa开发者_StackOverflow中文版ct, apparently a website can have up to 20 seperate cookies.

Ok - fair enough.

But why on earth would you store more than say "UserID", and why would you possibly need 20 cookies?


If you offer the user a way to customize your site you need to store their settings somewhere. You might need cookies for:

  • user settings
  • the session id
  • the contents of a shopping basket
  • the last item viewed
  • the user login


Some that I can think of:

  • persistent login cookie
  • session cookie
  • user-independent settings
  • user-tracking-cookie


It's a choice. If you don't need 20 cookies, it doesn't mean somebody else won't.


Agree with PiedPiper and thejh. If you are storing user info and customizing the behaviour of your site based on users actions, then very soon you will run out of storage limit of single cookie.


A site can have multiple pages, and a lot of those pages may have some information that might in turn be stored in cookies. It is ironic that you ask WHY you may want to use a lot of cookies where as I have seen a lot of people complaining why ONLY 20!!!

It is a good practice to ensure that you DO NOT create a lot of cookies, simply because IE has 20 cookie limit. Other browsers may have more [or less]!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜