At 22:14 24.11.2002, Øystein Håland said:
>In the purpose of getting access to 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 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

There seems to be an inconsistency between (again) MSIE and other
Mozilla's. I found this function on that seems to handle these

// ----------------------------------------------------------------------------
// sess_setcookie()
// ----------------------------------------------------------------------------
function sess_setcookie($name, $value, $expDays=0, $expHours=0, $expMins=0,
$expSecs=0) {
    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) +
    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 . ";
    return true;

   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to