Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cookies on CGI-installed PHP & IIS 5

    I'm having some problems login-in and logout with my script. I searched the posts in php.net and came up with the conclusion that it has something to do with the CGI-installed PHP running on IIS 4/WinNT.

    It seems that the same problem happens for sessions as well.

    login.php:
    Code:
    setcookie("cookiename",$username, time()+9600);
    logout.php:
    Code:
    setcookie("cookiename","", time()-9600);
    At times I was able to login but unable to logout. After I deleted the cookie manually from the browser, I was unable to login again.
    print_r $_COOKIE; was always empty when I cannot login.

    Does anyone has a workaround for this? I'm afraid the chances of getting the host to re-install PHP as ISAPI is near to impossible.

    thanks
    Last edited by celestine; 10-05-2004 at 10:09 AM.

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok. i searched the web and google and found it to be a known bug (not sure if its php or iis 4) either way, the bug has been documented in PHP.

    I found a workaround (quick and dirty) but it does the trick. I thought it might be useful to someone, so I'll post it.

    I included another file in the login after verifying a user's access via database. In that included file, I set a meta refresh and a link (for those who don't wish to wait). The meta refresh goes back to the index page just as the usual header() tag would.

    IIS 4 on NT or even IIS 5 doesn't read the cookie (or register) if you have a header directly after setting the cookie. I tried for days and it just wouldn't work. The meta refresh after works. You can probably use javascript redirect too.

    Same for logout, have to use meta refresh instead of header.

    This is only for PHP installed on NT in CGI. The ISAPI one didn't have the same problem.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •