Hi I'm not real good with coding, so here goes: I have two scripts at end of page, one after the other: <script src="http://mysite.com/script1.php" type="text/javascript"></script> <img src="http://mysite.com/script2.php" style="width:1px; height:1px;"> The first one creates some unique ID, and posts it in cookie of user. The second one waits for 2 seconds, then reads the ID from the cookie and inserts it into a table. However all the IDs that go into the table are 0 (meaning that when the second script accesses the cookie, it gets null). Anyone has an idea why is it happening? Thanks.
Are you sure the cookie is being written to the browser? Look for it and read the data. How are you reading the cookie? Without any code on how you are doing it, it's really hard to help you. I can't read minds yet. Lol.
If you creating a cookie using php means. The cookie cannot get read in that page itself. U need to navigate to another page than only u can read that cookie using php. (or) If you creating a cookie using javascript "document.cookie = " means. You can access that cookie within that page itself using document.cookie. to check Ur cookie is added in that page after add your cookie. Put alert(document.cookie);