I'm having a really strange problem and I'm hoping someone can help me with debugging this issue.

I have a PHP script which starts a php session using session_start(), then sets a cookie to save the value of the php session ID like this:

setcookie("PHPSESSID", "12345678", 0, "/", "$hostname", 1,1);

Then, on a 2nd page, I have a piece of Javascript code which is trying to access the cookie contents like this:

var x = document.cookie;

the alert statement comes up empty. now, i should add that if I print out the $_COOKIE array using PHP , I can print out the cookie contents correctly. Only when using Javascript to access the cookie value (which I should be able to do, since the javascript is running on the same domain that the cookie is set for, so there should be no security issues)

I've been banging my head against this wall for the past 10 hours. any help would be greatly appreciated !!!