At 22:14 24.11.2002, Øystein Håland said: --------------------[snip]-------------------- >In the purpose of getting access to mydomain.se/ha/ I will set a cookie: >setcookie ("login", "OK", time()+3600, "/ha/"); >It looks like the cookie is set since I get the confirmation text (of course >placed inside the codeblock where the cookie is 'set' (?). Probably it just >confirm that it has found ONE hit in the db on the username/password pair). >But, when I try to access any file in mydomain.se/ha/ it fails and the login >script is loaded again (and a look in 'Temporary Internet Files' tells the >cookie doesn't exist). On the local machine (w2k, apache 2) the same script >works ok --------------------[snip]--------------------
There seems to be an inconsistency between (again) MSIE and other Mozilla's. I found this function on php.net that seems to handle these differences: // ---------------------------------------------------------------------------- // sess_setcookie() // CODE TAKEN DIRECTLY FROM http://www.php.net/manual/en/function.setcookie.php // ---------------------------------------------------------------------------- function sess_setcookie($name, $value, $expDays=0, $expHours=0, $expMins=0, $expSecs=0) { /*********************************** Notes: This is a really simple cookie function. Use expDays, expHours, expMins and expSecs to set the expiration time. If it's too user-friendly, feel free to remove that feature. It should handle all browsers, although I've only tested it on MSIE 6 (Win 2k, sp3). I coded it with both Microsoft and Netscape's Specs in mind. If you find any errors, let me know at: "cookieHeader .AT. inxil .DOT. com" (formatted to avoid spam). ***********************************/ $exp = ($expDays * 86400) + ($expHours * 3600) + ($expMins * 60) + $expSecs; if (ereg("MSIE", getenv("HTTP_USER_AGENT"))) { $time = mktime()+$exp; $date = gmdate("D, d-M-Y H:i:s \G\M\T", ($time)); header("Set-Cookie: $name=$value; expires=$date; path=/;"); } else { header("Set-Cookie: $name=$value; expires=" . time()+$exp . "; path=/;"); } return true; } -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php