Setting cookie information is quite common on e-com sites, especially if the availability of the products are location based. For instance, the site I was working on resells Phone/Internet packages. The site requires that upon arriving at the site, the customer is prompted to choose the province they would like to be shopping under. That province is then stored as a cookie value. Then, when the user clicks on the category they would like to shop under, they are prompted to enter a postal code. The postal code is then used to grab a value from a database. That value is the Internet or Phone provider available in the area the customer is enquiring in. That value, as well as the Postal Code are then saved as cookie values, and the product collection displayed is filtered by the Provider value in the cookie; which is also a product attribute in the Magento store.
All this is quite trivial. Setting cookie values in Magento is as simple as instantiating the cookie model, and calling set() on that model. The problem, however, with this structure comes in when using full page cache, which is available on Enterprise licenses of Magento. Full page cache is an extremely useful feature on sites, especially those with a lot of products, where page load times can be burdened by heavy collections. However in this case, if the customer is viewing a collection under, lets say, the “Internet Packages” category, and using one postal code, but then wishes to change their postal code and check the same category caching will cause an issue. Instead of reloading the collection, a cached page, will just be displayed which will contain the collection shown for the previous postal code.
Its times like this, where page caching becomes a hindrance rather than help. If you plan on using full page cache, while displaying a dynamic collection… well, you can’t. One of the ideas I played with was loading the collection using ajax. However if you are using page cache, but then loading the collection a new on the category pages anyways, what’s the point? Disabling page cache is the only realistic option, however its only useful if you are displaying a small collection on the category page. If you are displaying a large amount of items, page times will be effected, as well as the customer’s experience.