Cookies for anonymous users aren't read nor checked
Instead of making a custom cookie, try using Drupal's cookie system.

Set:

user_cookie_save(array('key' =&gt; 'value'));


Get:

var = $_COOKIE['Drupal_visitor_key'];




I just realised this is in php, not javascript as you have used so I will expand.  I made my overlay by creating a new page with hook_menu and am using hook_init to check for cookie values, redirecting to my new page if required.