As we'll see, cookies are quite safe and, when used properly, do not in any way violate the privacy of visitors to your site. When they were first introduced, however, cookies got a bad rap. As a result, some users choose to disable them just because someone they know said that cookies were bad. For this reason, relying on cookies for the basic functions of your site can sometimes be a risky proposition. The main reason for not using cookies as a drop-in replacement for variables, however, is convenience.
Variables are extremely convenient.
It takes one line of code to set a variable, and making use of the value stored in a variable usually just involves putting the name of the variable where you'd like the value to appear. Cookies are a good deal more complex, and have a few limitations that would get in the way. That's all I'll say on this for now, as the rest should become clear by the end of this article. Don't let my talk of complexity and limitations scare you away, though. Finally, we'll develop a simple example of a cookie in action, the complete code for which will be provided.