Refs #4239 Fixing bug and adding custom variables cookie setter

TODO: we need some tests to make sure this works as expected and will not be broken in the future
 *  Test new visit without a cookie: cookies 'ses' and 'id' should be created,
 *  Test new page view: the 'ses' cookie should be deleted and 'id' cookie updated
 *  Test new visit where the visitor has a cookie created with Piwik.JS: PiwikTracker should read the cookie as expected