Fastcgi php cookie problem [Answered]RSS

13 replies

Last post Sep 28, 2007 05:49 PM by Merri

  • Fastcgi php cookie problem

    May 27, 2007 04:36 AM|zopal|LINK

    It seems only the last php setcookie() is set when you issue more than one after eachother on IIS7 with Fastcgi (x64 longhorn)

    I had made a copy of the php directory from my old IIS5 server (same executable, extensions, php.ini, etc...) to make sure to have the same environment.

    The code:

    <?
    setcookie ("cookie1", "one");
    setcookie ("cookie2", "two");
    ?>

    wfetch output:
    started....
    Reusing existing connection (source port 51778)\n
    REQUEST: **************\n
    GET /ctest.php HTTP/1.1\r\n
    Host: localhost\r\n
    Accept: */*\r\n
    \r\n
    RESPONSE: **************\n
    HTTP/1.1 200 OK\r\n
    Content-Type: text/html\r\n
    Server: Microsoft-IIS/7.0\r\n
    X-Powered-By: PHP/5.2.1\r\n
    Set-Cookie: cookie2=two\r\n
    X-Powered-By: ASP.NET\r\n
    Date: Sun, 27 May 2007 09:42:57 GMT\r\n
    Content-Length: 2\r\n
    \r\n
    \r\n
    finished.

     

    Normally the output should look like this (this is my old IIS5 server's output):

    started....
    resolve hostname "www.test.info"
    WWWConnect::Connect("1.1.1.1","80")\n
    source port: 51800\r\n
    REQUEST: **************\n
    GET /ctest.php HTTP/1.1\r\n
    Host: www.test.info\r\n
    Accept: */*\r\n
    \r\n
    RESPONSE: **************\n
    HTTP/1.1 200 OK\r\n
    Server: Microsoft-IIS/5.0\r\n
    Date: Sun, 27 May 2007 09:51:54 GMT\r\n
    MicrosoftOfficeWebServer: 5.0_Pub\r\n
    X-Powered-By: ASP.NET\r\n
    Connection: close\r\n
    X-Powered-By: PHP/5.2.1\r\n
    Set-Cookie: cookie1=one\r\n
    Set-Cookie: cookie2=two\r\n

    Content-type: text/html\r\n
    \r\n
    \r\n
    WWWConnect::Close("1.1.1.1","80")\n
    closed source port: 51800\r\n
    finished.

     ps: I had tried with the x64 php executables and the result is the same.

     ps2: If I change to cgi (not fastcgi), it works well with the same executables

    PHP FastCGI IIS7

  • Re: Fastcgi php cookie problem

    May 30, 2007 12:57 AM|rickjames|LINK

    Hi zopal,

    There definitely was a bug there and it should be fixed in the latest bits (http://blogs.iis.net/rickjames/archive/2007/04/19/fastcgi-tp2-unofficial-update-70419.aspx). Please could you give 'em a try and see if the problem still repros?

    Thanks,

    Rick.

     

  • Re: Fastcgi php cookie problem

    May 30, 2007 02:35 PM|zopal|LINK

    Hi,

     I had tried, but the result is the same.

    I had extracted the iisfcgi.dll from iis7-tp2update-70419-x64.EXE  (98816 bytes 2007.04.19 08:21:20, 7.0.6001.16502) and replaced the %windir%\SysWOW64\inetsrv\iisfcgi.dll  (7.0.6001.16510)

     I'm using LH beta3 the original dll was newer version it seems.

     Thanks,
    Zopal

  • Re: Fastcgi php cookie problem

    May 31, 2007 09:52 PM|rickjames|LINK

    Hi Zopal,

    If you're running 64-bit, then you'll need to replace two binaries:

    Put the x64 iisfcgi.dll in system32\inetsrv.

    Put the x86 iisfcgi.dll in syswow64\inetsrv.

    (I think everyone gets zapped at least once cause the 64s and 32s don't match)

    Thanks,

    Rick

  • Re: Fastcgi php cookie problem

    Jul 02, 2007 05:37 PM|zopal|LINK

    Hi Rick,

     Sorry for the late answer, I just had the possibility to try it.

     Now I had installed the newer dlls, but the result is the same, cookies aren't work.

     Thank you,

    Zopal

  • Re: Fastcgi php cookie problem

    Jul 13, 2007 11:37 AM|rickjames|LINK

    Hi Zopal,

    I copied your script and tried it again and it still works for me. Are you triply sure you're running 70419? This would be easy to debug on the latest Server 2008 builds, cause there's a tracing event called GENERAL_RESPONSE_HEADERS. Do you already have access to a newish 2008 build? Otherwise we'll need to do some ntsd debugging. Have you used ntsd before?

    Thanks,

    Rick.

    REQUEST: **************\nGET /setcookie.php HTTP/1.1\r\n
    Host: localhost\r\n
    Accept: */*\r\n
    \r\n
    RESPONSE: **************\nHTTP/1.1 200 OK\r\n
    Content-Type: text/html\r\n
    Server: Microsoft-IIS/7.0\r\n
    X-Powered-By: PHP/5.2.3\r\n
    Set-Cookie: cookie1=one\r\n
    Set-Cookie: cookie2=two\r\n
    X-Powered-By: ASP.NET\r\n
    Date: Fri, 13 Jul 2007 15:29:53 GMT\r\n
    Content-Length: 0\r\n
    \r\n

  • Re: Fastcgi php cookie problem

    Jul 16, 2007 04:34 PM|zopal|LINK

    Hi Rick,

     Finally I had found the problem...

    I used Total Commander to copy the file, which is a 32bit executable. (For reference, for 32bit programs  the %windir%\SysWOW64 directory mapped as %windir%\system32, not the real %windir%\system32 directory)

    After I had replaced the %windir%\system32\inetsrv\iisfcgi.dll I got the following error message:

    The configuration section 'system.webServer/fastCgi' cannot be read because it is missing a section declaration

    If I replaced back the original iisfcgi.dll, this error is message disappeared.

    After the investigation I had found that originally in the %windir%\System32\inetsrv\config\schema\IIS_schema.xml file the dectaration was 'system.webServer/fastCGI'  (Last 2 letters in capital) and in the %windir%\System32\inetsrv\config\applicationHost.config the declaration was the same:

    <section name="fastCGI" allowDefinition="AppHostOnly" overrideModeDefault="Deny" /> 

    <fastCGI>
                <application fullPath="E:\php\php-cgi.exe" />
    </fastCGI>

     but in the new %windir%\System32\inetsrv\config\schema\iisfcgi_schema.xml I found the following:

    <sectionSchema name="system.webServer/fastCgi"

     (last two letters are in small caps)

    After I had corrected the %windir%\System32\inetsrv\config\applicationHost.config file, everything works fine, I just changed the following lines:

    <section name="fastCgi" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />

            <fastCgi>
                <application fullPath="E:\php\php-cgi.exe" />
            </fastCgi>

    And finally:

    started....WWWConnect::Close("195.56.189.106","80")\nclosed source port: 51393\r\n
    WWWConnect::Connect("195.56.189.106","80")\nsource port: 51548\r\n
    REQUEST: **************\nGET /ctest.php HTTP/1.1\r\n
    Host: web.zomputer.hu\r\n
    Accept: */*\r\n
    \r\n
    RESPONSE: **************\nHTTP/1.1 200 OK\r\n
    Content-Type: text/html; charset=iso-8859-2\r\n
    Server: Microsoft-IIS/7.0\r\n
    X-Powered-By: PHP/5.2.3 (x64)\r\n
    Set-Cookie: cookie1=one\r\n
    Set-Cookie: cookie2=two\r\n

    X-Powered-By: ASP.NET\r\n
    Date: Mon, 16 Jul 2007 20:09:30 GMT\r\n
    Content-Length: 2\r\n
    \r\n
    \r\n
    finished. 

     

     Zopal

    FastCGI IIS7 php fastcgi

  • Re: Fastcgi php cookie problem

    Sep 27, 2007 07:56 AM|Merri|LINK

     I'm still having the same problem after updating fastcgi. I have a different setup, 32-bit Vista. PHP + MySQL are both working.

    I did the update and applied the same fix as in the above post, fastCGI -> fastCgi. However,  the difference I have is that I don't have a mention of fastcgi in IIS_schema.xml - should it be there? The cookie problem still continues despite the update, only the last cookie set remains. Getting pretty clueless on what I can still do.
     

    For background, I first had PHP installed as ISAPI, and I actually haven't removed that. I've only changed the file extension to something different. That installation didn't work, I got PHP reporting some Access Denied error each time it tried to set cookies. This also crashed PHP until I restarted IIS7.

  • Re: Fastcgi php cookie problem

    Sep 27, 2007 09:51 AM|anilr|LINK

    To use fastcgi on vista, upgrade to the sp1 beta which was just released earlier this week.

    Anil Ruia
    Software Design Engineer
    IIS Core Server
  • Re: Fastcgi php cookie problem

    Sep 27, 2007 03:32 PM|Merri|LINK

    Thanks, but SP1 beta of what? I can't locate such a download with Google or on this site (in downloads or in blog posts).

  • Re: Fastcgi php cookie problem

    Sep 27, 2007 09:26 PM|rickjames|LINK

  • Re: Fastcgi php cookie problem

    Sep 28, 2007 07:50 AM|Merri|LINK

    Apparently this means I should be a member of something to be able to download it.

    However, now that I've tested more, the cookie problem seems to be somehow related to one site only as one another seems to run fine. Have to go through the code when I have the time to look at it.

  • bills bills

    415 Posts

    Microsoft

    Re: Fastcgi php cookie problem

    Sep 28, 2007 02:55 PM|bills|LINK

    Note, if you want to make this scenario work with the built-in CGI (not fastCGI) feature, you'll want to get this patch:  http://blogs.iis.net/bills/archive/2007/09/25/iis7-patch-for-windows-vista-fixes-cgi-php-applications-that-send-multiple-response-headers.aspx

    ~~~~~~~~~~~~~~~~~~~~~~~~
    Bill Staples
    Product Unit Manager, IIS
    blog: http://blogs.iis.net/bills
  • Re: Fastcgi php cookie problem

    Sep 28, 2007 05:49 PM|Merri|LINK

    Ok, the bug was only there because of a missing check for all the required cookies. The earlier buggy fastcgi had added only one of them. So after fixing fastcgi when there was only one of the cookies, code assumed everything is ok at that point and didn't go for the logged out route. But, it is now working nicely :) 

     Thanks everyone.