I am using the following cookie:
var $j = jQuery.noConflict();
$j(document).ready(function(){
if (document.cookie.indexOf(\'visited=true\') == -1)
document.cookie = valuename + "=" + value + "; " + expires + ";domain=;path=/";
This "domain=;path=/"; will take dynamic domain as its cookie will work in subdomain.
It will work if you want to test in localhost.
Add ;path=/ to make your cookie into a site cookie. See this article on JavaScript Cookies for more details.