For years I thought I understood “cookie” very well. Especially when I figured out it’s a great way to share data between JavaScript and PHP. I always got results as I expected in many projects with this approach.
“Why not just saving the values to database and just use PHP to access it?” you might be asking. Most of the cases are because we need to access such values in JavaScript. For example, we have an eCommerce website and we let the user chooses her location with a lightbox window. The lightbox should only appear once and after the user makes the choice, it just goes away.