PHP mechanisms for addressing cookies are to do with handling HTTP headers. See separate "DOCheaders" for general basics; this file for cookies specifically. ======================== Very basically: cookies are varname-value pairs, sent by servers to client browsers, and sent back by the browsers to give session state. Basically each cookie has not 2 but 4 attributes: Varname Value Expiry time. (Unix time in seconds. If 1 it means expire whenn browser quits) Server+file-dir it was sent from/by ======================== I need to get cookies working, not least for login to moodle within PHP. When developed, will be in myfilegetcontents() Test case bed is prCERE.php $_COOKIE is a super global. $_COOKIE['name'] htmlspecialchars($_COOKIE["name"]) setcookie(), getcookie(), setrawcookie() [normally auto encode, decode: so vars hold the unencoded version.] setcookie(, , expiretimestamp e.g. time() + 3600, e.g. '/', e.g. '.fims.moodle.gla.ac.uk'); 0 for timestamp means at end of browser session setcookie("TestCookie", $value); setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */ setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1); http://uk3.php.net/manual/en/function.setcookie.php Next strategy?: Try printing a cookie Do getcookie, resend cookie (and add username='guest'). password=guest testcookies=1 or try without this. Or see if simply having a sesskey cookie and ignoring the rest will work. MORE NOTES: java cookies You can set a cookie in java. Could this be useful? (It's proposed on web as part of a sol. for getting PHP to see Anchor tags in URL.) Main use may be in dealing from me as server with clients: if the page I send them creates cookies from their input values, then I don't have to send them a 2nd page. This sets it, and refresh of the page gets it to the server/PHP. Have to explore: 1. Does this overwrite other cookies for same server/page? No. it looks like a single string var; but actually it accumulates cookies. 2. How to control duration of cookie (session only, etc.) Yes; see examples; duration = 0 means when browser closes. 3. ?Can set cookies for other servers? No. But maybe try doing a re-location but staying in the java script and setting cookies in that? If doing re-loc doesn't terminate the java. document.cookie = 'ppkcookie2=another test; expires=Fri, 3 Aug 2001 20:47:11 UTC; path=/' http://www.quirksmode.org/js/cookies.html http://www.w3schools.com/js/js_cookies.asp http://en.wikipedia.org/wiki/HTTP_cookie