Naming cookies - best practices

Viewed 33877

What should cookie names look like?

Should they be:

  • lower_case
  • CamelCase
  • Underscore_Camel_Case
  • UPPER_CASE

Or should they be something else?

5 Answers

Keep in mind that this cookie is sent with every request, so imho, just use the smallest name you can, and document your code nicely.

I use whatever style the coding standards for the project call for.

Generally I prefer camelCase for naming schemes, but whichever one pays the bills is the one I'll go with.

Maybe you won't like my answer:

Don't use your own cookies but store data in server sessions. So you only need one cookie (to reference the session id) and how you name that plays no role.

Related