<p>I want to increment a cookie value every time a page is referenced even if the page is loaded from cache. What is the "best" or most concise way to implement this?</p>

Most of the old cookie handling functions I've seen use simple string manipulations for storing an retrieving values, like
this
example, you can use other libraries, like
cookie-js
, a small
(< 100 lines)
utility for cookie access.
I personally use jQuery on my projects, and I use the
jQuery Cookie Plugin
, it's really simple to use:
```
```
var cookieName = "increment";

if ($.cookie(cookieName) == null){
  $.cookie(cookieName, 1, { expires: 10 });
}else{
  var newValue = Number($.cookie(cookieName)) + 1;
  $.cookie(cookieName, newValue, { expires: 10 });
}
```
```