<p>When I first downloaded the <span>cookiechoices.js</span> file from the link suggested by Google and then installed it onto my site it didn’t really work correctly. It would display the message but when the user clicked on the ok button the Cookiechoices cookie only seemed to be getting set for that specific page, so when a second page was visited the cookie message would be displayed a second time. <br /><br /></p><h2>Cause of the Error</h2><p>The reason for this was that the cookiechoices code was not setting the path correctly. You can see the Path that the cookie sets by going to “More tools->Developer tools” within Chrome and then selecting the Application tab and expanding Cookies within the Storage tree structure. As you can see in this example the path /abap has been included as part of the cookie properties. This is not what you want, it should just be a ‘/’ like all the others. In this case the cookie will only be set for all pages within the /abap directory rather than the whole website.</p><a draggable=”false” href=”http://www.se80.co.uk/training-education/wp-content/uploads/2016/11/cookiechoices1.png”><img draggable=”false” src=”http://www.se80.co.uk/training-education/wp-content/uploads/2016/11/cookiechoices1.png” alt=”CookieChoices Path Error” width=”949″ height=”294″ /></a> CookieChoices Path Error<h2>Solution</h2><p>The solution is actually quite simple but took me a lot of messing around to find. You basically just need to hard code the path property to be the route of your website. To do that within the cookie choices code recommended by google simply find the following section of code <strong>document.cookie = cookieName + ‘=y; expires=’ + expiryDate.toGMTString();</strong> Now simply add “path=/” after =y; <strong>i.e.</strong> Resultant JavaScript code will now look like this: <strong>document.cookie = cookieName + ‘=y; path=/; expires=’ + expiryDate.toGMTString();</strong> </p><h2>Test</h2><p>Once you have implemented the above fix and uploaded the new file to you website try a page where the cookie choices message is displayed and click the OK button again. The result should be that the cookie is set for the route of the website.</p><a draggable=”false” href=”http://www.se80.co.uk/training-education/wp-content/uploads/2016/11/cookiechoices2.png”><img draggable=”false” src=”http://www.se80.co.uk/training-education/wp-content/uploads/2016/11/cookiechoices2.png” alt=”cookiechoices fix” width=”777″ height=”22″ /></a> cookiechoices fix